dataset question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a dataset that contains the following XML:

<NewDataSet>
<WDisp>
<ADDRESS>123 Main St </ADDRESS>
<DISTANCE>5658</DISTANCE>
<PARCELID>5658</PARCELID>
</WDisp>
<WDisp>
<ADDRESS>234 Eml St </ADDRESS>
<DISTANCE>1987</DISTANCE>
<PARCELID>1685</PARCELID>
</WDisp>
<WDisp>
<ADDRESS>345 Maple St </ADDRESS>
<DISTANCE>65</DISTANCE>
<PARCELID>6785</PARCELID>
</WDisp>
</NewDataSet>

I would like to get the ADDRESS column into XML by itself like this:

<ADDRESS>123 Main St </ADDRESS>
<ADDRESS>234 Eml St </ADDRESS>
<ADDRESS>345 Maple St </ADDRESS>

What is the easiest way to do this? Stylesheet? Put into a DataTable?
Other? Could you provide a link to an example page or just provide some code?
 
YOu have a few ways, you can iterate through the datarows and then look for
the address column - you can use XSLT or you can use an XPathNodeIterator.
The most straightforward way if you don't know the XPath library is probably
just looping through the rows.
 
Xpath is your answer.

The Xpath query is "//ADDRESS" in this case. Really short.

If your XML below is accurate and you aren't using namespaces, then Xpath
becomes even simpler, since you don't need to specify the namespace manager.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
 
Back
Top