开发者

XML parse error [closed]

开发者 https://www.devze.com 2023-04-07 20:45 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally app开发
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally app开发者_JAVA技巧licable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

I have a Valid XML.

It asked me to treat the entire metadata record as the value of metadata element "dataxml", with newlines (and percent signs) indicated by percent signs (i.e. “percent-escaped”)

so i have done the following

Note: It asked me percent only the following : \n,\r, : and % so i only str_replaced those

$input .= 'dataxml: ' . str_replace(array(chr(hexdec('3A')),chr(hexdec('25')),chr(hexdec('0A')),chr(hexdec('0D'))),array('%3A', '%25', '%0A', '%0D'), $xmlfile) . "\n";

But it pops out the following error:

400 error:'dataxml': XML parse error: xmlns: URI http%253A//dataxml.org/schema/kernel-2.1 is not absolute

Can any one point out what i have done wrong?


The colon in http:// is being replaced twice: first the colon is replaced by %3A then the percent in that replacement is being replaced by %25.

You can use the function strtr() to avoid replacing already replaced parts of the string.

For example,

$input  .= 'dataxml: ' . strtr($xmlfile, array(":" => "%3A", "%" => "%25", "\n" => "%0A", "\r" => "%0D")) . "\n";
0

精彩评论

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

关注公众号