You are here:  » What to do if several instances of one field


What to do if several instances of one field

Submitted by jovian on Thu, 2006-12-21 13:11 in

Below you'll see an example post from a XML-file with bookdata I'm currently working with. I have a problem when field AKTOER_BOK NAVN exists in 2 or more variants.

POST data shows that in the first instance of AKTOER_BOK NAVN the ROLLE-tag is "Author", in the next it is "Translator". Both data are needed in the database I'm updating..

So, is there some way to fetch both? (array from Magicparser?)

I guess I ignore something here, but for the moment the return is only the latter one, AKTOER_BOK NAVN = "Rodge, Isak".

All help is highly appreciated. Thank you in advance!

here is the sample post:

<LEVERANSE>
<POST>
<ISBN>0340832894</ISBN>
<ISBN13>9780340832899</ISBN13>
<AKTOER_BOK NAVN="Le Carré, John" ROLLE="Author"/>
<AKTOER_BOK NAVN="Rodge, Isak" ROLLE="Translator"/>
<TITTEL HOVED="Absolute friends"/>
</POST>
</LEVERANSE>

Submitted by jovian on Thu, 2006-12-21 13:22

Hi again - I am very sorry for wasting bytes in your forum-database!

Your excellent online demo gave me the answer. It gave the following result:

AKTOER_BOK
AKTOER_BOK-NAVN Le Carré, John
AKTOER_BOK-ROLLE Author"
AKTOER_BOK@1
AKTOER_BOK@1-NAVN Rodge Isak
AKTOER_BOK@1-ROLLE Translator

I'm impressed - Magicparser rules!

Have a nice christmas!

:)

Submitted by jovian on Thu, 2006-12-21 13:57

More questions

My MagicParser doesn't return AKTOER_BOK@1-NAVN or AKTOER_BOK@1-ROLLE as the demo does..

Any ideas?

Only AKTOER_BOK-NAVN is returned in outdata.

Submitted by support on Thu, 2006-12-21 14:54

Hello Per,

This is probably because you are using the wrong format string in your code. If the XML is short, it may not have auto-detected correctly. Based on your example XML, the format string you need to be using is:

xml|LEVERANSE/POST/

You will then see the additional instances resolved correctly...

Cheers,
David.

Submitted by jovian on Fri, 2006-12-22 11:40

Everything works great now, after downloading latest version using my registration code.

Problem solved!

Per