Showing posts with label feed. Show all posts
Showing posts with label feed. Show all posts

Saturday, March 31, 2012

subset of data using dataview?

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.comThis is because you are still grabbing all the rows from the underlying
table. The underlying table never changes, but the dataview can filter which
rows you see.

You should be looking at the Item property of the DataView to get each row
as filtered from the dataview instead.

"Guoqi Zheng" <no@.sorry.com> wrote in message
news:ulC57xn3DHA.1428@.TK2MSFTNGP12.phx.gbl...
> 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
Hi,

> 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??

You should loop through DataView' DataRowView:
foreach (DataRowView drv in dv)

Write...(drv["name"]);

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

Saturday, March 24, 2012

suggestions for RSS Feed url?

I have been getting into RSS quite a bit lately and I would like to try my
hand at writting one. What is the best suggestions for the URL? Should it
be an aspx returning XML? Should it be an HttpModule (or handler? what's
the other way?) or some other mechanism?
If you've written one, I would love to hear about your experiences. If you
have any website urls I would love to see them too. I've tried googling,
but I seem to get drowned in plain-jane, end user rss feed stuff, not too
much developer oriented or url info. Maybe it's my keywords?
Thanks."Flip" wrote ...

>I have been getting into RSS quite a bit lately and I would like to try my
>hand at writting one. What is the best suggestions for the URL? Should it
>be an aspx returning XML? Should it be an HttpModule (or handler? what's
>the other way?) or some other mechanism?
Isn't it usually just an xml file? I might be wrong, I dont know - but I
like you would like to get into writing one...

> If you've written one, I would love to hear about your experiences. If
> you have any website urls I would love to see them too. I've tried
> googling, but I seem to get drowned in plain-jane, end user rss feed
> stuff, not too much developer oriented or url info. Maybe it's my
> keywords?
I did find this which looks like a good start, and helpfully there's both C#
and VB examples for the .net part...
http://www.uberasp.net/getarticle.aspx?id=17
HTH
Rob
Another option for the url is the rss prefix. I was hunting in RSSBandit's
feed xml and found this one for CBC.
http://rss.cbc.ca/topstoriesnews.xml
> http://www.uberasp.net/getarticle.aspx?id=17
Very ! I'll read up on that during lunch! :> Thanks for the quick
feedback. Hopefully we'll both get some more urls from other's.
Thanks again.
"Flip" wrote ...

> Thanks again.
More than welcome :o)
Rob
> More than welcome :o)
I didn't get a chance to play with this last night. :< I hope to try it out
tonight and get back to you with a sample URL. If you try it out, COOL! If
not, hey, at least you led me in the right direction to learn something new!
:>
Have a good one.