Groups | Blog | Home
all groups > dotnet xml > december 2003 >

dotnet xml : How to read data from xml? please help.


david
12/5/2003 9:06:24 PM
In my xsl, I call a C# function in extension object. So I pass the current
context, the parameter type is XPathNodeIterator, my xml is like this

....
<i>
<id>1</id>
<name>name 1</name>
</i>
<i>
<id>2</id>
<name>name 2</name>
</i>
.....

in the C# function, I want to get a list of value in id tag sperated with
comma, like "1,2.....".

What is the best way to retrieve that data from the xml?

Thanks!

Oleg Tkachenko
12/7/2003 3:23:47 PM
[quoted text, click to view]

Well, consider you've got XPathNodeIterator you can write something like
this (add comma logic yourself):

while (ni.MoveNext()) {
XPathNodeIterator id = ni.Current.SelectChildren("id", "");
if (id.MoveNext())
Console.WriteLine(id.Current.Value);
}
--
Oleg Tkachenko
XML Insider
http://www.tkachenko.com/blog
AddThis Social Bookmark Button