I have the following in an XML file:
<entry>
...
<link href="http://www.example.com/somelink" />
...
</entry>
I want to extract the “href” attribute. I’ve been getting my list of elements like so:
Dim productsDoc = XDocument.Parse(productXML.ToString())
Dim feed = From entry In productsDoc...<entry> Select entry
For Each entry In feed
Dim product As New CartItem
...
product._productid = entry.<id>.Value
product._permalink = entry.<link>.Value 'HOW DO I GET THE ATTRIBUTE?
allItems.Add(product)
Next
How do I extract the <link> href attribute?
Thanks!
Hi to get the link you should use the “XML Attribute Axis Property“. This allows you to easily access attributes.
You can use it like this:
Here’s a full working example of usage: