I'm trying to write a windows phone 7 app which reads from an xml using xdocument but i'm having a few problems.
If I do this:
Dim xml As XDocument = XDocument.Load(e.Result)
System.Diagnostics.Debug.WriteLine(xml.ToString)
Or this:
System.Diagnostics.Debug.WriteLine(xml.Elements.Value.ToString)
then the xml data is output to the immidiate window as a string proving that the data exists but if i do this:
Dim products = From product In xml.Descendants("product") _
Select title = product.Element("title").Value
For Each product In products
System.Diagnostics.Debug.WriteLine("Title" & product.title)
Next
I get nothing for product.title and I also get nothing when I do stuff like this:
Dim count As Integer = xml.Descendants("count").Value
What am I doing wrong? Thanks.
xml looks something like this:
<productslist>
<count>2</count>
<products>
<product>
<productId>1</productId>
<title>test item 1 </title>
<price>4.99</price>
<category>
<categoryId>1</categoryId>
<categoryName>cat 1</categoryName>
</category>
</product>
<product>
<productId>2</productId>
<title>test item 2</title>
<price>10.99</price>
<category>
<categoryId>2</categoryId>
<categoryName>cat 2</categoryName>
</category>
</product>
</productslist>