Skip to main content
Inspiring
March 28, 2012
Answered

Ghost data from XML file

  • March 28, 2012
  • 1 reply
  • 926 views

Hi Scripters,

I got ghost data from my XML file by the import.

In the XML file are 3 times the parent content 'HALSRIEMEN-GEFL' but I get it 5 times, I have no idea anymore and hope anybody see the problem.

My scheme:

<products-profdog>

  <product>

    <item-id></item-id>

    <type></type>

    <title></title>

    <additive></additive>

    <description></description>

    <category></category>

    <volume-unit></volume-unit>

    <weight></weight>

    <matchcode></matchcode>

    <ean-number></ean-number>

    <price-unit></price-unit>

    <stock></stock>

    <parent></parent>

    <active-shop></active-shop>

    <active-catalog></active-catalog>

    <sort></sort>

  </product>

  <product>

    <item-id></item-id>

    <type></type>

    <title></title>

    <additive></additive>

    <description></description>

    <category></category>

    <volume-unit></volume-unit>

    <weight></weight>

    <matchcode></matchcode>

    <ean-number></ean-number>

    <price-unit></price-unit>

    <stock></stock>

    <parent></parent>

    <active-shop></active-shop>

    <active-catalog></active-catalog>

    <sort></sort>

  </product>

</products-profdog>

My loop:

for (i = 0; i < myRootXMLElement.xmlElements.length; i++) {

     for (ii = 0; ii < myRootXMLElement.xmlElements.item(i).xmlElements.length; ii++) {

          if(myRootXMLElement.xmlElements.item(i).xmlElements.item(ii).markupTag.name == 'parent'){

               if(myRootXMLElement.xmlElements.item(i).xmlElements.item(ii).contents == 'HALSRIEMEN-GEFL'){

                    alert( myRootXMLElement.xmlElements.item(i).xmlElements.item(ii).markupTag.name + ' -> ' + myRootXMLElement.xmlElements.item(i).xmlElements.item(ii).contents );

               }

          }

     }

}

This topic has been closed for replies.
Correct answer _mm

If the empty tag exist like this <parent/> the problem still is there..


Got it.

There was a wrong XML import setting.

It has to be removeUnmatchedExisting = true;

1 reply

Jongware
Community Expert
Community Expert
March 28, 2012

If you show the entire tag tree for the item you find in your alert, you can see if the data gets duplicated (same tag order) or this text simply occurs more than you thought (same text, different tags).

_mmAuthor
Inspiring
March 28, 2012

Hello Jongware,

in the XML file the ghost products don't have a parent tag. I have no idea why I get it in this loop.

If I add this tags with any input I don't get this problem... Is it possible to check this or is it impossible without filled tags from XML file?

Got the same issue if the XML file has included the tags, if they are empty the import is wrong..

_mmAuthor
Inspiring
March 28, 2012

If the empty tag exist like this <parent/> the problem still is there..