stebbi
04-09-2009, 11:27 AM
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, 11:28 AM
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 &
a better solution but bloated in your case:
<description><![CDATA[testing & test]]></description>
best regards
stebbi
04-09-2009, 11:37 AM
Thanks I need it to be in the code there will be clients uploading the file cant be sure they will use & can I expect this problem with any other characters?
oesxyl
04-09-2009, 11:54 AM
Thanks I need it to be in the code there will be clients uploading the file cant be sure they will use & 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:
& -> &
< -> <
> -> >
' -> '
" -> "
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, 08:39 PM
It's worth mentioning that the entities (as they're called) in oesyxl's post also work with HTML.