Jack Fox wrote:
I'm navigating through a XPathDocument consisting of mostly mixed complex
type elements (i.e. innertext plus more elements). When I use
XPathNavigator.Value to retrieve the text I get everything between <mytag>
and </mytag>, the text I'm looking for, but also all the text portion of
every sub tag (but not the tags themselves).
Is there a method in the MVP XML library or some other work around I can
user to get only the text of the parent tag?
I am not sure I understand what you want exactly (some XML sample would
have helped) but if you want the text of child text nodes then you could
select those e.g. if the navigator is positioned on your mytag element
XPathNodeIterator iterator = navigator.SelectChildren(XPathNodeType.Text);
and use the iterator to get those text node values and concatenate them
(using string concatenation or a StringBuilder if needed) e.g.
string childText = "";
while (iterator.MoveNext()) {
childText += iterator.Current.Value;
}
// now use childText here
The element itself has no text, anything in there is a child node.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/