0

I need to get values from a couple xml files that vary.
Ex. one file could contain:

<typeB>
<people.b>  
  <person.1>    
    <fname.1>brian</fname.1>
    <lname.1>smith</lname.1>
  </person.1>
  <person.11>
    <fname.1>joe</fname.1>
    <lname.1>carey</lname.1>
  </person.11>
</people.b>
</typeB>

and another would replace B with A and even have an extra group

<typeA>
<people.a>  
  <person.2>
   <name>
    <fname.2>brian</fname.2>
    <lname.2>smith</lname.2>
   </name>
   <address.2>
    <street>123 pine street</street>
   </address.2>
  </person.2>
  <person.22>
    <fname.2>joe</fname.2>
    <lname.2>carey</lname.2>
  </person.22>
</people.a>
</typeA>

I would need to get any nodes that contain "fname" or "lname" regardless of the number that comes after or what the parent nodes are. Would this be possible without knowing the path?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pradeepsimhanp
0

Hi,

Assuming testDoc is your XmlDocument variable, you can try like this testDoc.DocumentElement.GetElementsByTagName("fname*");

Thanks,
Pradeep

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.