I'm reading and writing XML-files with Microsoft XML Core Services 6.0 (MSXML). When writing element-content with "special" chars that have to be escaped in the context of xml, like writing "&" as & i dont have to care about this because MSXML does this conversion. This means, if i assign a text to an element, e.g. oXMLElement.Text = "1 & 2" , MSXML actually writes oXMLElement.Text = 1 & 2 when i create a XML-file. Thats pretty nice and saves me some work.

Now, what i want to do, is to "de-mask" XML-strings automatically. So, i read from a XML-file with the selectNodes-method, which works by adding an XPath-statement, e.g. //ns:element/text(). Unfortunately, the result-string i get looks like 1 & 2 and not like 1 & 2. Is there a way to tell the MSXML-object or maybe the XPath-statement to give me an "de-masked" string? I´m using MSXML with ObjectPal / Paradox, so the best solution would be a method from the MSXML-library or a "special" XPath- statement.

有帮助吗?

解决方案

What you're seeing is the "escaped" XML notation for the text. This is what you should see if you use the .xml property to retrieve the string.

To get the string without the escapes, use .nodeValue.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top