XmlWriter comlex usage with a XmlReader
I im going to read file by xmlReader and insert a child elements into this object by XmlWriter and save the output. How i can parse data between this two classes? I know that SimpleXml is already exists and makes it easy. but i have a huge amount of the data and i need to make it faster then SimpleXml can. It is only teory and i havnt code yet, i need only to get answer only by these qwestions: Is creating two objects reader/writer and their work Is faster then similar via SimpleXml ? How does it possible to use xmlReader object and parse data parts into XmlWriter?
XMLWriter
is not only faster than SimpleXML
, but also takes less memory. Especially when you need to handle large amounts of data (as you do), you should use XMLWriter
as with larger data speed really starts to matter.
Of course, you can have a XMLReader
and a XMLWriter
at the same time. And you would do it just as you wrote: read from the XMLReader
and write it immediately to the XMLWriter
.
edit: I found some nice statistics (and also a code sample) here. Reading that, I also learned that SimpleXML takes less memory than the XMLWriter, which surprises me a little...so my initial statement seems to be only 50% true. Faster: yes, less memory: no.
链接地址: http://www.djcxy.com/p/64746.html上一篇: XML:如何不从根元素执行XPath查询