The XML file is here. How can I get the source content in this XML file?
3
-
My god that xml is fugly. Why would you want to get anything from it anyway?dar7yl– dar7yl2009-11-10 07:19:07 +00:00Commented Nov 10, 2009 at 7:19
-
This file is simply. the ms office 2007 docx file xml ooxml is more fugly.Bruce Dou– Bruce Dou2009-11-10 07:30:02 +00:00Commented Nov 10, 2009 at 7:30
-
DOM is good -> $document = new DOMDocument(); $document->load($extrato); $root = $document->getElementsByTagName("OFX")->item(0); $stmttrn = $root->getElementsByTagName("STMTTRN");devasia2112– devasia21122012-05-11 17:45:42 +00:00Commented May 11, 2012 at 17:45
Add a comment
|
2 Answers
Actually there are four relatively simple ways to read an XML file:
DOMwhich uses the DOM API (and therefore has to load the whole document into memory)SimpleXMLwhich provides a very simple and elegant way to parse XML documents (but lacks a lot of document manipulation methods), it also loads the whole document into memoryXMLReaderis a stream-based XML pull parser. It's usage is not as intuitive as the usage of both other options above, but it can be a life-saver when you have to parse large documents (as it does not need to load the whole document into memory and operates on the XML stream). The nice thing is that it allows you to inter-operate with theDOMviaXMLReader::expand().XML Parseris a very low-level component which allows you to create SAX parsers, which means that you define handler functions which will be called when reading the XML file; essentially they have the same benefits as theXMLReader(operating on streams)
My personal favorites are:
SimpleXMLwhen parsing relatively small XML files without the need to modifiy themXMLReaderwhen parsing large XML files
1 Comment
devasia2112
DOM is the good one -> $document = new DOMDocument(); $document->load($extrato); $outer = $document->getElementsByTagName("your_outer_tag")->item(0); $inner = $outer->getElementsByTagName("your_inner_tag");
PHP already includes XML parsers in the core or as extensions (i recommend SimpleXML).
Try to use it and then ask us if you have any specific problem.