A
Arthur Dent
Hello All...
I am in an app that needs to write out an XML document for transmittal to an
outside organization. All good and fine... I create the XmlDocument object,
append all my nodes, and values etc etc... and it all works.
Now I go to save the file... I tried two methods...
MyXmlDocument.Save(filename) and
My.Computer.FileSystem.WriteAllText(filename, MyXmlDoc.OuterXml, False)
The problem comes in with XmlDocument.OuterXml. According to XML, there are
5 characters which need to be escaped... Ampersand, LessThan, GreaterThan,
Apostrophe and DoubleQuote. XmlDocument.OuterXml, escapes only three of
these ( & , < and > ). Apostrophe and DoubleQuote do not get escaped. This
is a problem, because the third party we need to deal with *must* have them
escaped, even inside of a Nodes InnerText.
So I figured okay, I'll just escape them myself, but when I try to do that,
it winds up escaping my Ampersand (for example in """ ), so that it
winds up saving "&quot;".
How in the world can I tell it that it needs to escape ALL FIVE CHARACTERS?
Thanks in advance,
- Arthur Dent.
I am in an app that needs to write out an XML document for transmittal to an
outside organization. All good and fine... I create the XmlDocument object,
append all my nodes, and values etc etc... and it all works.
Now I go to save the file... I tried two methods...
MyXmlDocument.Save(filename) and
My.Computer.FileSystem.WriteAllText(filename, MyXmlDoc.OuterXml, False)
The problem comes in with XmlDocument.OuterXml. According to XML, there are
5 characters which need to be escaped... Ampersand, LessThan, GreaterThan,
Apostrophe and DoubleQuote. XmlDocument.OuterXml, escapes only three of
these ( & , < and > ). Apostrophe and DoubleQuote do not get escaped. This
is a problem, because the third party we need to deal with *must* have them
escaped, even inside of a Nodes InnerText.
So I figured okay, I'll just escape them myself, but when I try to do that,
it winds up escaping my Ampersand (for example in """ ), so that it
winds up saving "&quot;".
How in the world can I tell it that it needs to escape ALL FIVE CHARACTERS?
Thanks in advance,
- Arthur Dent.