finding a specific child node

  • Thread starter Thread starter apandapion
  • Start date Start date
A

apandapion

I'm new to programatic manipulation of XML, and I'm sure I'm not doing
everything in the best way. In specific, I have a number of pieces of
code that look like this:

string foo="";
foreach (XmlNode xnii in xni.ChildNodes)
{
switch (xnii.Name)
{
case "foo":
foo = xnii.InnerText;
break;
}
}

There's a better way to write that code block, I'm sure, but I'm
working to reach a deadline to provide some XML interfaces to some Java
coders and I don't have time to research best practices beyond relying
on the generosity of the group.

TIA,
ap
 
Hello, (e-mail address removed)!

a> There's a better way to write that code block, I'm sure, but I'm
a> working to reach a deadline to provide some XML interfaces to some Java
a> coders and I don't have time to research best practices beyond relying
a> on the generosity of the group.

You can use XmlNode.SelectSingleNode(...) XmlNode.SelectNodes(...)

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top