471,347 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,347 software developers and data experts.

dataset question

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?
Aug 19 '05 #1
2 1087
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.
"CLEAR-RCIC" <CL*******@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com...
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?

Aug 19 '05 #2
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.
--
"CLEAR-RCIC" <CL*******@discussions.microsoft.com> wrote in message
news:54**********************************@microsof t.com...
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?

Aug 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Simon Harvey | last post: by
2 posts views Thread by Simon Harvey | last post: by
reply views Thread by Mike | last post: by
15 posts views Thread by JIM.H. | last post: by
4 posts views Thread by markerussell | last post: by
22 posts views Thread by Arne | last post: by
2 posts views Thread by JT | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.