简体   繁体   中英

Modify and output into a XML file in Java

I have a XML parser (finished) could deal with a subset of XML files. However, currently I have a XML file could not directly process by my parser.

There are two options to me:

1). I have to add more code on my parser;

2). maybe I can do some pre-processing before I feed the XML file into my parser;

My Question is:

Is there any way to modify XML file (delect tags and create entities)?

BTW: the output of pre-processing should be also XML file.

In fairness, unless you're willing to repeatedly extend your XML parser or your preprocesser, there will always be XML files that your current parser can't handle.

So it worth considering whether that's a good approach or whether it's worth switching to an existing XML parser. The benefits of that is that you don't need to extend the parser or write a preprocessor, it's then a matter of utilizing the features of that XML parser.

If you're writing this XML parser for learning purposes then it's worth extending the parser itself. It really depends on the feature that you'd need to implement but it doesn't seem right to have parser that lacks functionality and then to remedy that with a preprocessor.

Of course, there may be situations where it's faster or more effective to use a preprocessor instead but your question currently doesn't include enough information to decide on that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM