Escape characters in InnerXml

  • Thread starter Thread starter Ian Walsh
  • Start date Start date
I

Ian Walsh

XmlDocument oXmlDoc = new XmlDocument();
oXmlDoc.Load(filename);
node = oXmlDoc.SelectSingleNode("//config/ldap/userpath");
Console.Write(node.InnerXml);

The value I get is:

\r\n\t\t\tOU=Walshy,OU=GroupServices,OU=organizations,OU=Portal,DC=portaladdev,DC=intranet,DC=local\r\n\t\t

I know this is because of the format of the xml doc. The question is,
how do I get the value from the element without the escape characters?

Example of xml doc is as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<config>
<ldap>
<userpath>
OU=Walshy,OU=GroupServices,OU=organizations,OU=Portal,DC=portaladdev,DC=intranet,DC=local
</userpath>
</ldap>
</config>

Thanks.
 
Ian Walsh said:
XmlDocument oXmlDoc = new XmlDocument();
oXmlDoc.Load(filename);
node = oXmlDoc.SelectSingleNode("//config/ldap/userpath");
Console.Write(node.InnerXml);

The value I get is:

\r\n\t\t\tOU=Walshy,OU=GroupServices,OU=organizations,OU=Portal,DC=po
rtaladdev,DC=intranet,DC=local\r\n\t\t

My guess is that you're looking in the debugger.
I know this is because of the format of the xml doc. The question is,
how do I get the value from the element without the escape characters?

The escape characters aren't actually there - the actual tabs, carriage
returns etc are there though. If you don't want them, use String.Trim.
 
Back
Top