G
Guoqi Zheng
Dear sir,
New to ASP.NET, help will be appreciated.
I need to create a XML file for product feed. In our business, one product
always belongs to more than 1 categories. I need to have a XML file like.
<product id = "105">
<Name>whatever</Name>
<Categories>
<Category name = "Category1"/>
<Category name = "Category2"/>
.....
</Categories>
</product>
I can use a dataset which get the data from product table. However, my
question is that how can I get a sub set data of category. The category
rows varies depends on the product id. I am thinking to use dataview filter.
The following is my code.
.......
dvCategory = New DataView(dtCategory)
strView = "ProductId='"&r("ProductId")&"'"
dvCategory.RowFilter= strView
For Each rCat in dvCategory.Table.Rows
Writer.WriteStartElement("category")
Writer.WriteAttributeString("name",
rCat("CatName")&r("ProductId"))
Writer.WriteEndElement()
Next
....
It will write out all the categories instead of only those categories this
product belongs to. Any idea what did I do wrong or how can I achieve this??
Thanks in advanced.
Guoqi Zheng
Tel: 0031-23-5343545
http://www.meetholland.com
New to ASP.NET, help will be appreciated.
I need to create a XML file for product feed. In our business, one product
always belongs to more than 1 categories. I need to have a XML file like.
<product id = "105">
<Name>whatever</Name>
<Categories>
<Category name = "Category1"/>
<Category name = "Category2"/>
.....
</Categories>
</product>
I can use a dataset which get the data from product table. However, my
question is that how can I get a sub set data of category. The category
rows varies depends on the product id. I am thinking to use dataview filter.
The following is my code.
.......
dvCategory = New DataView(dtCategory)
strView = "ProductId='"&r("ProductId")&"'"
dvCategory.RowFilter= strView
For Each rCat in dvCategory.Table.Rows
Writer.WriteStartElement("category")
Writer.WriteAttributeString("name",
rCat("CatName")&r("ProductId"))
Writer.WriteEndElement()
Next
....
It will write out all the categories instead of only those categories this
product belongs to. Any idea what did I do wrong or how can I achieve this??
Thanks in advanced.
Guoqi Zheng
Tel: 0031-23-5343545
http://www.meetholland.com