Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading everything bellow XML node

Status
Not open for further replies.

majkinetor

Programmer
Feb 21, 2006
88
RS
Hi there.

Is there any quick way to read everything that is contained in XML node, similar to what InnerText represents to HTML. I want to get everything contained in that node.

<elem>
<child1>text<child1>
<child2>text<child2>
</elem>

I want to get this string if I am currently on <elem> :

string s = <child1>text<child2>\n<child2>text</child2>

Is there any simple way to do this ? Currently I use XML namespace and XPathNodeIterator to walk all fields and generate XML "again":
Code:
XPathNodeIterator iter = iter1.Current.SelectDescendants(XPathNodeType.Element, false);
s = "";
while ( iter.MoveNext() )
s += "<"+iter.Current.Name+">"+ iter.Current.Value +"</>iter.Current.Name + ">"

And I want to do something like this (pseudocode)
s = iter1.Current.InnerText();

to achieve the same.

thank you.


}
 
And one off topic question ?
Where is that edit button here ?
 
Ok, you can replay just to my second question.

The class that provides me mentioned behavior is XmlNode.. I don't know how I didn't see InnerText property....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top