Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Classes for XML Building  RSS feed

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written a program for creating XML documents which uses the Document and DOM classes. The problem I face is when a large of data needs to be stored in the XML file. The program terminates throwing a OutOfMemory error. I earlier used the Document class to read an already generated XML file but this also used to give me the same error so I started using SAXParser. My question is, is there a light-weight XML document builder to avoid such errors being thrown up? Any kind of help is welcome.
 
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A DOM occupies much more space than the data it represents since it creates so many objects.

The simplest XML document builder is to just use print statements to write the tags and contents. If you organize your architecture so that objects represent reasonable chunks of the XML hierarchy, and "know how" to write their contents, it is pretty straightforward.

Bill
 
Ketan KC Chachad
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had read long time before that SAXParser can be used to create XML documents. Is it true? If yes, can you give me the links for reading on it.
 
It's exactly the same and completely different as this tiny ad:
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!