If you run this code
Import BaH.libxml
Local XmlDoc:TxmlDoc = TxmlDoc.NewDoc("1.0")
Local Node:TxmlNode = TxmlNode.Newnode("story")
XmlDoc.SetRootElement(Node)
Node.AddChild("code1",Null,"<1>")
Node.AddChild("code2",Null,"<2>")
Node.AddChild("code3",Null,"<1&2>") 'This line produces an error
XmlDoc.SaveFormatFile("test.xml",True,"utf-8")
It will generate the error error : unterminated entity reference 2>
If you look at the resulting file, you will see that '<' and '>' are converted to '<' and '>' like it should, but '&' produces an error instead. It works if you convert the string before passing to AddChild()
Import BaH.libxml
Local XmlDoc:TxmlDoc = TxmlDoc.NewDoc("1.0")
Local Node:TxmlNode = TxmlNode.Newnode("story")
XmlDoc.SetRootElement(Node)
Node.AddChild("code1",Null,"<1>")
Node.AddChild("code2",Null,"<2>")
Node.AddChild("code3",Null,"<1&2>".Replace("&","&")) 'replaces '&' with '&'
XmlDoc.SaveFormatFile("test.xml",True,"utf-8")
Reading an xml doc works correctly, converting '&' to '&' as expected.
|