This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Two Questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Two Questions" Watch "Two Questions" New topic
Author

Two Questions

JohnWilliam Fitz
Ranch Hand

Joined: Oct 13, 2008
Posts: 80
Hi.

I'm new to working with XML in Java. I have two questions...

* Where's the FAQ for this forum? I searched the forum for "faq" first, I swear.
* I am overwhelmed by the number of options. I think I have come across a least a dozen different ways to write/update xml from java. Which one should I use? My needs are very simple: updating (that is writing to already existing) xml files of small size and rather simple structure.

Thanks,
John
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
The link to the FAQ seems to have gone missing at some point; I've restored it to the forum home page. It doesn't have a whole lot content yet, though.

It's largely a matter of personal preference. Using DOM has the advantage of not requiring any additional libraries (it's built into the JRE), although that's not often an important consideration.


Ping & DNS - my free Android networking tools app
JohnWilliam Fitz
Ranch Hand

Joined: Oct 13, 2008
Posts: 80
Ulf Dittmer wrote:It's largely a matter of personal preference. Using DOM has the advantage of not requiring any additional libraries (it's built into the JRE), although that's not often an important consideration.


Thanks Ulf.

Actually, I always like to go for the built-in solutions first, and abandon them only when my needs exceed their capabilities. So I will start with DOM.

Another question: Does writing XML with DOM mean I should be using the LSXxx classes? Like LSSerializer and LSOutput?

Gruss,
John
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Yes. You'd obtain a DOM Document object from an XML file using JAXP, and would then use the DOM classes Document, Node and Element to modify the document.

For output, DOMImplementationLS.createLSOutput and LSOutput.setCharacterStream or LSOutput.setByteStream allow you to send the XML to a file or elsewhere.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Two Questions
 
Similar Threads
Passed the IBM-141
Use of XML Parser
Suse Professional / Personal
Just passed IBM XML Certification with 79%
Is there java class to parse xml nodes?