...

View Full Version : xml help please



stebbi
04-09-2009, 12:27 PM
I have an xml file that is uploaded to the database but if theres( & ) in there it wont upload and I get this error "parser error : Extra content at the end of the document"


<catalog>
<product>
<curl>www.company.com</curl>
<title>test & testing</title>
<description>testing & test</description>
</product>
</catalog>

Thanks for your help

oesxyl
04-09-2009, 12:28 PM
I have an xml file that is uploaded to the database but if theres( & ) in there it wont upload and I get this error "parser error : Extra content at the end of the document"


<catalog>
<product>
<curl>www.company.com</curl>
<title>test & testing</title>
<description>testing & test</description>
</product>
</catalog>

Thanks for your help

replace & with &amp;

a better solution but bloated in your case:

<description><![CDATA[testing & test]]></description>


best regards

stebbi
04-09-2009, 12:37 PM
Thanks I need it to be in the code there will be clients uploading the file cant be sure they will use &amp; can I expect this problem with any other characters?

oesxyl
04-09-2009, 12:54 PM
Thanks I need it to be in the code there will be clients uploading the file cant be sure they will use &amp; can I expect this problem with any other characters?
yes, any character which is not allowed in xml must be replace by it's entity, that means:


& -> &amp;
< -> &lt;
> -> &gt;
' -> &apos;
" -> &quot;

The alternative is to use CDATA sections. If the user upload the file I suggest to use a schema to validate it when they upload.

My apologize that I didn't explay why in my previos replay.

best regards

Alex Vincent
04-09-2009, 09:39 PM
It's worth mentioning that the entities (as they're called) in oesyxl's post also work with HTML.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum