2003-11-17 kl. 17.06 skrev Chris Hayes:


Need to read a xml-file into an array, but searching around I havent found a way that's easy and simple… Arent there an easy way in PHP to accomplish this?

have you been at http://se.php.net/xml ?

Well, I've, and I also have to say that the XML-support in PHP lacks any usability…


2 pages code later I still cannot get it to work, and the manual is pretty thin on this chapter...

For example, I've the following XML:

<ingrediens>
<ingrediensnummer>1234</ingrediensnummer>
<maengde>3,4</maengde>
<enhed>kg</enhed>
</ingrediens>

Here I thought that the startelementfunction should be called upon every start tag, the character_data_handler on every text string and the endelement function on every endelement.


But what seems to happen is that the character data handler is called to randomly number of times, and if I output the current element every time it gets called I get the following output for the xml above:

ingrediens
ingrediens
ingrediens
ingrediensnummer
ingrediensnummer
ingrediensnummer
ingrediensnummer
maengde
maengde
maengde
maengde
enhed
enhed
enhed
enhed
enhed
enhed

What I expected to get was:

ingrediensnummer
maengde
enhed

So, couldnt anyone please bring some clarity into this matter?

Sincerely

Victor
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to