I have used xml.UnMarshal method to get a struct object but it has it's own limitations. I need a way where I can get all the descendants of a particular type inside a node without specifying the exact xpath.
For example, I have an xml data of the following format:
<content>
<p>this is content area</p>
<animal>
<p>This id dog</p>
<dog>
<p>tommy</p>
</dog>
</animal>
<birds>
<p>this is birds</p>
<p>this is birds</p>
</birds>
<animal>
<p>this is animals</p>
</animal>
</content>
Now I want to traverse through the above xml and process each node and it's children in that order. The problem is that this structure is not fixed and order of elements may change. So I need a way so that I can traverse like
While(Content.nextnode())
{
switch(type of node)
{
//Process the node or traverse the child node deeper
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…