RJones February 2016

I am trying to retrieve the text between Nodes but it is returning all child nodes too.

<Inspection>
<Certificate>
Retrieve This Text Only 
<Status>ACTIVE</Status>
</Certificate>
</Inspection>

I am using:

foreach (XmlNode node in nodes)
{
     array = node.SelectSingleNode("Certificate").InnerText;
}

it returns:

Retrieve This Text Only 
<Status>ACTIVE</Status>

I only need "Retrieve This Text Only"

Answers


Steve Wellens February 2016

I don't know what language you are using but the XPath required to get what you want is this:

//Certificate/child::text()

Post Status

Asked in February 2016
Viewed 3,021 times
Voted 8
Answered 1 times

Search




Leave an answer