How are you simplifying it? Removing attributes and/or fields? This could be done
most efficiently using a stream if you do not need to see the whole tree before you prune the xml. That is to say: i each time you encounter attribute x, you do not want to put it into the new xml, but you do want to put attribute y, then you might use
SAX. This way you could include/exclude elements as you come to them.
However, if you need to analyze the whole tree before you decide how to simplify it, then you should use DOM.
The difference is that SAX parsers are event based and return items as they finds them, whereas DOM parsers read the entire document and then builds the tree. You then querry the tree.
Both of the links ( to SAX and DOM ) include links to documentation and sample code.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.