I'm going to parse a nested xml file using PowerShell. Is there a way to traverse its childnodes and the nodes of its child one by one?
For example:
<?xml version="1.0"?>
<root xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<Node1 name="A"/>
<Node2 name="B"/>
<Node3>
<Element1 id="1" type="Element">
<State value = "live" /State>
<Child1 name="dogName">
<SubChild1 id="11111">
</SubChild1>
</Child1>
<Child2>
<SubChild2 name="color" value="red" />
<SubChild2 name="skin" value="none" />
<SubChild2 name="other" value="lost" />
</Child2>
<Child3>
<SubChild3>FlagMark=GO</SubChild3>
<SubChild3>Dog</SubChild3>
</Child3>
</Element1>
<Element2 id="2" type="Element">
<State value = "live">
<Child1 name="catName">
<SubChild1 id="22222">
</SubChild1>
</Child1>
<Child2>
<SubChild2 name="color" value="brown" />
<SubChild2 name="skin" value="thick" />
<SubChild2 name="other" value="unknown" />
</Child2>
<Child3>
<SubChild3>FlagMark=Run</SubChild3>
<SubChild3>Cat</SubChild3>
</Child3>
</Element2>
<Element3>
...
</Element3>
</Node3>
</root>
How can I get each child node of by its name and value? How can I get child nodes of one by one and print?
The element type "State" must be terminated by the matching end-tag "</State>"