0

I'm trying to rip values from a simple XML file that contains duplicate nodes under the same name. For example, the node Stats may have 50 child nodes all named user and 10 child nodes named Finances.

For a very large number of child nodes with the same name, I do not know of any way to use xml_parse_into_struct, so I normally use DOMDocument. However, say if all nodes had unique names, which would be faster between the three? Sometimes I would use strrpos to get the position of say, <cash> and then search for the next occurrence of </cash>. I would continue until I'm done through the document. However, how does this compare with DOMDocument's getElementsByTagName('cash') and xml_parse_into_struct?

I am looking for general advice regarding parsing XML files in PHP, with emphasis on speed. I normally use DOMDocument for everything because it is most convenient, but when I have to load 100 thousand XML files, any increases in speed is much appreciated.

1

1 Answer 1

0

he's got a point. use xml_parser. it's an event driven parser for xml.

http://php.net/manual/en/book.xml.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.