Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
XML error '&' FromString and FromFile (escape ampersand)
#1
Sorry for this basic question, I could swear I have seen this covered somewhere in the forum but can not find topic anymore.

I get the below error if I read a xml file with an '&' in it.
Quote:0x80070057, The parameter is incorrect.


Macro Macro4
Code:
Copy      Help
str s=
;<?xml version="1.0" ?>
;<rootelem>
,;<elem>
,,;<cc>&text of cc 2</cc>
,;</elem>
;</rootelem>
IXml x=CreateXml
x.FromString(s)
err
,out x.XmlParsingError

I used code from helpfile to explain.
The error always occurs at first occurence of '&'
Content of 's' comes from file. (originally the it was x.FromFile(xmlfile))
The only way I can think of is replace '&' with it's character code [38] just before 'FromString' and then replacing it back just before 'ToString'?
Is there a better/propper way? Or should I use character code replacement method?
#2
& must be &amp;
#3
THANK YOU!!!


Forum Jump:


Users browsing this thread: 1 Guest(s)