You are here:  » parsing xml structure


parsing xml structure

Submitted by grissom on Mon, 2011-07-25 10:50 in

hello

I've xml structure, where are placed 3 other tree structure:

<?xml version="1.0" encoding="utf-8"?>
<katalog data="2011-07-04 10:57" md5="18569B86ACF458DBDFF75817201683A5">
  <GrupyTowarowe>
    <GrupaGlowna id="MAT" nazwa="_Materiały reklamowe">
      <PodGrupy>
        <PodGrupa id="MAT-REK" nazwa="Materiały reklamowe" />
      </PodGrupy>
    </GrupaGlowna>
  </GrupyTowarowe>
  <producenci>
    <producent id="BEZ" nazwa="_" />
  <producenci>
  <produkty>
    <produkt id="AGAAKPOKF0001" nazwa="Filtr węglowy AKPO (FR-6350)- okapy WK-4, WK-5, WK-7" producent="AKP">
      <zdjecia>
        <zdjecie plik="/Pictures/AGA/OKF/AGAAKPOKF0001/1.jpg" domyslne="1" data="2011-05-19" />
      </zdjecia>
      <technika>
        <parametr nazwa="Kod Producenta" opis="WK-4, WK-5, WK-7 (FR-6350)" jm="" typ="varchar" />
        <parametr nazwa="Opis" opis="Filtr węglowy do okapów AKPO z oznaczeniem WK-4, WK-5, WK-7" jm="" typ="varchar" />
        <parametr nazwa="" opis="Opakowanie zawiera 1 sztukę" jm="" typ="varchar" />
      </technika>
    </produkt>
  </produkty>
</katalog>

When I'm trying to get data from xml, like this:

MagicParser_parse("hurtownie_xml/action.xml", "addCategories", "xml|katalog/grupytowarowe/grupaglowna/");
//MagicParser_parse("hurtownie_xml/action.xml", "addProducers", "xml|katalog/producenci/");
/MagicParser_parse("hurtownie_xml/action.xml", "addProducts", "xml|katalog/produkty/produkt/");

MagicParser doesnt end the script, it stops after last node for "grupaglowna", same problem with "producenci", but with produkt everything is ok. Could you tell me, where is the problem?

Submitted by support on Mon, 2011-07-25 11:14

Hi grissom,

There is an error in the XML you posted, the closing producenci element is wrong:

  <producenci>
    <producent id="BEZ" nazwa="_" />
  <producenci> <<<< this line

..it should be:

  <producenci>
    <producent id="BEZ" nazwa="_" />
  </producenci>

That should be all it is...

Hope this helps!
Cheers,
David.

Submitted by grissom on Mon, 2011-07-25 11:47

Thanks for quick reply, unfortunatelly this was my mistake ;(, I've cut this xml, couse it has 35mb :), and paste wrong tag.
I'll check on smaller xml file, is script stop working.

Its doesnt help, either file is small or big, script not finishing it self, you have to manually stop the script.

Submitted by support on Mon, 2011-07-25 11:52

Hi grissom,

Please could you email me either the .zip XML file, or a link to it, and I'll check it out on my test server for you...

Cheers,
David.