You are here:  » Making own XML file doesn't work


Making own XML file doesn't work

Submitted by formmailer on Mon, 2008-08-11 06:21 in

Hi David,

I am trying to create a XML file that can be parsed by MagicParser, but whatever I try, it can't be parsed.

Below is the XML I try to use:

<?xml version="1.0" encoding="iso-8859-1"?>
<!--Generated on 2008/08/11 (http://www.bijnavakantie.nl)-->
<products>
<product>
<place>1</place>
<name>Appartementen Dosjoimi, Costa Brava</name>
<price>279,- p.p. | 4 personen | 8 dagen</price>
<productURL>http://zomer.bizztravel.nl/tradetracker/?tt=216_0_16631_&r=%2Fvakantie%2Fspanje%2Fcosta-brava%2Flloret-de-mar%2Fappartementen-dosjoimi.html</productURL>
<imageURL>http://images.bizztravel.nl/pics/1203343612.jpg</imageURL>
<date>20 september 2008</date>
</product>
<product>
<place>2</place>
<name>Appartementen Dosjoimi, Costa Brava</name>
<price>279,- p.p. | 4 personen | 8 dagen</price>
<productURL>http://zomer.bizztravel.nl/tradetracker/?tt=216_0_16631_&r=%2Fvakantie%2Fspanje%2Fcosta-brava%2Flloret-de-mar%2Fappartementen-dosjoimi.html</productURL>
<imageURL>http://images.bizztravel.nl/pics/1203343612.jpg</imageURL>
<date>20 september 2008</date>
</product>
</products>

I'm sure something is wrong with this XML, but I can't figure what it is.
Can you help me?

Thanks!

/Jasper

Submitted by support on Mon, 2008-08-11 07:17

Hello Jasper,

The XML is not valid because of the "&" character in each of the productURL fields.

There are 2 ways to deal with this.

The first option is to use the XML Entity for "&" which is "&amp;". This would make your productURL fields something like:

<productURL>http://zomer.bizztravel.nl/tradetracker/?tt=216_0_16631_&amp;r=%2Fvakantie%2Fspanje%2Fcosta-brava%2Flloret-de-mar%2Fappartementen-dosjoimi.html</productURL>

The second option is to wrap the field in CDATA tags, which informs XML that all it is all literal data:

<productURL><![CDATA[http://zomer.bizztravel.nl/tradetracker/?tt=216_0_16631_&r=%2Fvakantie%2Fspanje%2Fcosta-brava%2Flloret-de-mar%2Fappartementen-dosjoimi.html]]></productURL>

Hope this helps!
Regards,
David.

Submitted by formmailer on Mon, 2008-08-11 09:39

Thanks David, it worked like a charm!

/Jasper