How to use ESC () character in XML?

前端 未结 1 2043
-上瘾入骨i
-上瘾入骨i 2020-12-11 21:53

I\'m trying this:


  text: 

But parser says:

org.xml.sax.SAXParseException; lineNumber:          


        
相关标签:
1条回答
  • 2020-12-11 22:50

    You cannot ( in XML 1.0). In XML 1.1 there is a slightly larger range of characters you can use, and the characters are expressed differently, but even then,  is 'restricted' (hex it is ) which, as far as I can tell, means that it is not valid XML, even though XML parsers should process it successfully. Note that the 'null' character (�) is never valid. Here's a Wiki article on these characters in XML

    You can try forcing the XML document to XML 1.1 and see if your parser will process it successfully.... set the first line of the XML to:

    <?xml version="1.1"?>
    

    In fact, I did that, and it works:

    <?xml version="1.1"?>
    <root>&#27;</root>
    
    0 讨论(0)
提交回复
热议问题