Parsing XML while ignoring comments/mixed context/PI
Hey everyone
Let's say I have three boolean variables representing whether or not to ignore comments, mixed context and PIs in an XML document
How would I go about to output the same XML file but without those three sections , depending on if they're true or false?
Are there features on parsers that you can set to ignore PI or ignore mixed context and such?
For example, if you would have this XML:
<root><?pi something><!--comment--></root>
and PI is set to false while comments is set to true, then the output should be
<root><!--comment--></root>
I tried for 2 hours to figure out how to start that or what to do but I'm really lost. Any help would be appreciated, Thanks
[776 byte] By [
deanat78a] at [2007-11-26 17:56:52]

# 2
Hi,
Yes there is method which will enable the parser to enable or disable the processing of comments,
signature is
public void setIgnoringComments(boolean ignoreComments)
Specifies that the parser produced by this code will ignore comments.
By default the value of this is set to false
i belive there are no such method to enable or disble the processing with PI.
You jst google
[url]http://java.sun.com/j2se/1.5.0/docs/api/index.html[/url]
Cheers!
# 3
yes, you can configure your parser for ignoring let's say text nodes.
however, personally, i would suggest not to do that because in the future, your code might run on some machine where the parser is not configured the same way yours was.
it is better to take care of these things in your own code but not parser.
just an experience sharing...
thanks