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…
Care to justify your statement? Because it doesn't work for you, it lacks usability? You are a usability expert?
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?
1. Post some code.
2. Read a tutorial http://www.meidomus.com/node/view/21 (that's one I wrote) http://www.google.com/search?q=parsing+xml+php (some that I didn't) -- Burhan Khalid phplist[at]meidomus[dot]com http://www.meidomus.com ----------------------- "Documentation is like sex: when it is good, it is very, very good; and when it is bad, it is better than nothing."
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php