开发者

create XML element with "$XYZ"

开发者 https://www.devze.com 2023-02-13 06:43 出处:网络
I am using java to create a root element the string resolves as shown below. Element root = doc.createElement(\"$XYZ\");

I am using java to create a root element the string resolves as shown below.

Element root = doc.createElement("$XYZ");

i get and exception

org.w3c.dom.DOMException: INVALID_CHARACTER_ERR: An invalid or illegal XML character is specified. 
    at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.createElement(Core开发者_运维百科DocumentImpl.java:618)

any advice on how do i create the element?


The '$' symbol is not allowed in the xml, therefore you are getting your exception.

'XYZ' would be allowed, but '$XYZ' is not allowed as it contains the '$'

You can see the w3 spec on the starting character here

0

精彩评论

暂无评论...
验证码 换一张
取 消