You can either just select the text via an XPath expression like this:
/parent/text()
or, if your XmlDocument is not too complex, you can position an XmlReader at
the text node and read it like this
<outlookCode>
string GetText( XmlReader reader )
{
string text = null;
while( reader.Read() )
{
if( "parent" == reader.LocalName )
{
reader.MoveToContent(); // this will move to the first text or
element node.
if( NodeType.Text == reader.NodeType )
{
text = reader.Value();
}
break;
}
}
}
</outlookCode>
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"Bjorn" <ba*******@tuvox.com> wrote in message
news:#0**************@TK2MSFTNGP10.phx.gbl...
Hi all,
Can't seem to figure out how to retrieve the text of a node with multiple
child nodes (and I just want the text of the parent, not the InnerText or
InnerXML that comes with it).
My doc looks something like this:
<parent attrib1 attrib2 attrib3>
Extractable string
<child>
some more text
</child>
<child>
yet more text
</child>
</parent>
What's the best way to return "Extractable string"?