Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying this:

<root>
  text: &#27;
</root>

But parser says:

org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 12; 
Character reference "&#27" is an invalid XML character.
  at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
  at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
  at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)

How to use it there?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
466 views
Welcome To Ask or Share your Answers For Others

1 Answer

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, &#27; is 'restricted' (hex it is &#x1B;) 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 (&#x00;) 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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...