http...">

Include a URL with a query string in an XML document

So, I have this XML document:

<?xml version="1.0" encoding="UTF-8"?> <Root> <Item> <URL>http://www.mysite.com/page?id=1</URL> </Item> </Root> 

When I try to view a document, I get an error message:

XML parsing error: malformed

on the = sign in the query string. I tried to change the = sign to %3D , but I get the same error in %

What am I supposed to do here?

+7
source share
3 answers

You can try the <URL><![CDATA[http://www.example.com/page?id=1]]></URL>

All text in the XML document will be parsed. But the text inside the CDATA section will be ignored by the parser. You can find more here .

+13
source

As you imagine it, XML is well formed. You have nothing to hide. You may have encoding problems in the source file. For information, the 2 characters you must execute in XML are:

 & in &amp; < in &lt; 

Characters you can avoid in attribute values ​​(depending on the syntax you use for attributes: attr='value' or attr="value" ):

 " in &quot; ' in &apos; 

Depending on the context, the last character that can be escaped:

 > in &gt; 
+16
source

try <URL><![CDATA[http://www.mysite.com/page?id=1]]></URL>

+1
source

Source: https://habr.com/ru/post/902023/


All Articles