Hello I am trying to read my xml document using xpath. I have been at it for few weeks now and just learning XML and VB but seems like I hit a road block. I tried a few different attempts at doing this and I have no problem displaying the XML file on a webpage using the xpathnavigator class. But then i needed to format into an html table so i took another route and just added the xmldatasource with a formview. So here is my code for that
<oriondata station='GiftShop'>
<meas name="GiftShopTime">2011/02/08 16:39:01</meas>
<meas name="GiftShopItemNumber">6</meas>
<meas name="GiftShopDuration">200</meas>
</oriondata>
The values I would like to grab are the date “2011/02/08 16:39:01” in this example and the number “6” and also the duration which is “200”
Not sure what I am doing wrong if i use the
<asp:Label ID="lblID" Runat="server" Text='<%# XPath("//oriondata/meas/@name") %>' /></b><br/>
That gives me “GiftShopTime” but not the actual time. Also if i just use this
<asp:Label ID="lblID" Runat="server" Text='<%# XPath(".") %>' />
</b><br/>
That gives me the current node from what I am reading but the current node when i do this happens to be the actual time
I just have not figured out a way to specify each of those names I thought this should work
Xpath("/oriondata/meas/name/@GiftShopTime")
but that displays nothing.
Your xpath needs to be changed to
The syntax of this particular xpath means “give me the value of the element meas who is a child of oriondata and whose attribute name has the value ‘GiftShopTime’ “.