Reputation:
Sample XML
<A>
<B>
<B1/>
<B2/>
<B3/>
<B4/>
<B5/>
</B>
<C>
<C1/>
<C2/>
<C3/>
<C4/>
<C5/>
</C>
</A>
Query: C# When I read the the child nodes of A it retuns nodes B & C with their child nodes.
Is there any possibility so that I can get only B & C without their respective child nodes
I need to populate the tree with this type of xml & the xml file is quite big. so I need to load the childs at the time of expanding any node
Requirement is Suppose I try to expand A node the I want only B & C,
If I expand B then I want B1 to B5
Upvotes: 1
Views: 2482
Reputation: 1
if i understand the question right, u need to get children of the node without getting their children. this can be done by xquery (child::*)
so if u apply it in A node it will give B and C. if u apply it in B then it will give B1-B5.
Upvotes: 0
Reputation: 823
Use a XmlReader. XmlDocument by design has to load the whole Xml document into memory.
Upvotes: 5
Reputation: 8776
It's a badly worded question so I'm not entirely sure what you are trying to do but if you just want all the child nodes of the root (A) then use an XmlDocument with XPath like this:
XmlDocument doc = new XmlDocument();
doc.Load(xmlFile);
XmlNodeList nodes = doc.SelectNodes("/A/*");
foreach(XmlNode node in nodes){
//DO STUFF
}
Upvotes: 1
Reputation: 35276
if you use java, you can implement a SAX Handler building your DOM and ignoring the children.
Upvotes: 1