You are here:  » XML attributes


XML attributes

Submitted by dataper on Wed, 2006-03-01 12:59 in

My XML-records of book-data looks like shown below, but how can I read those XML fields that have two attributes? Look at the field called TITTEL - it got one attribute called HOVED and another called UNDER. How can I read those using MagicParser ??

Please help- this is a bit urgent!

<POST>
<ISBN>072253535X</ISBN>
<ISBN13>9780722535356</ISBN13>
<AKTOER_BOK NAVN="Bach, Richard" ROLLE="Forfatter"/>
<TITTEL HOVED="Running from safety" UNDER="an adventure of the spirit"/>
<VAREEIER KODE="0006" NAVN="blablabla"/>
<FORLAG>Thorsons</FORLAG>
<BOKGRUPPE KODE="700" TEKST="Diverse"/>
<VAREGRUPPE KODE="49010" TEKST="Romaner, utenlandske"/>
<INNBINDING>Heftet</INNBINDING>
</POST>

Submitted by support on Wed, 2006-03-01 13:06

Hi,

I've uploaded your file to the demo script, which you can see at the following URL:

http://www.magicparser.com/demo?fileID=44059B213BB17&record=1
(will be deleted shortly!)

You can see, for example, that the TITTEL element as 2 attributes. These are "HOVED" and "UNDER". You can see the value of these attributes in the table as TITTEL-HOVED and TITTEL-UNDER.

To read the values in the code, you jused need to use those key names as the index to the $record array; for example:

<?php
  
function myRecordHanlder($record)
  {
    print 
$record["TITTEL-HOVED"];
    print 
$record["TITTEL-UNDER"];
  }
?>

Hope this helps - let me know how you get on;
Cheers,
David.

Submitted by dataper on Wed, 2006-03-01 13:34

Ohh, thank you VERY much David!
Actually I did that myself yesterday, but I didn't notice that neat feature! :)

I'm impressed, thanks!