Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

Retrieving Text strings in a mixed-content XmlElement

$
0
0

I have an XML Element that may contain elements, text or both. For example:

 

Code Block

<

testvalue="-360.0">

  <

testlogic="OR">

    fcs/heading-error-1 gt 180

    fcs/heading-error-2 gt 180

  </test>                     

  fcs/heading-error gt 180

  fcs/heading-error-3 gt 180  

</test>

 

 

I'd like to extract the text only from each element - and ONLY the text for that element and not child elements. The XmlElement InnerText and InnerXml members return strings that are not completely what I am looking for. For example, I'd like to get the text for the top-level element as:

 

Code Block

fcs/heading-error gt 180

fcs/heading-error-3 gt 180

 

And, I'd like to retrieve the nested test strings:

 

Code Block

fcs/heading-error-1 gt 180

fcs/heading-error-2 gt 180

 

Notice there are not even any comments there.

 

Am I correct in thinking that I'm going to have to do a lot of "manual" test processing? Or, is there a better approach?

 

Jon


Viewing all articles
Browse latest Browse all 935

Trending Articles