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开发者_开发问答.
he's got a point. use xml_parser. it's an event driven parser for xml.
http://php.net/manual/en/book.xml.php
精彩评论