Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

xml parsers does not read such a large file contents

 
Mohan rvscas
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,



am trying to parse and read the content from the above xml file.

am using dom parser and also i tried StAX parser to parse the xml contents.

but i cannot parse such a large file content.

could any one please help me to get out from this issue.

 
Paul Clapham
Sheriff
Pie
Posts: 20774
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What problems are you having, specifically, with the Stax parser? DOM parsers build a tree of the entire document, so if the document is big enough you will get out-of-memory exceptions. But I don't think you should have that problem with a Stax parser; I would expect it to break a very large text node into a number of Character events.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan rvscas wrote:
but i cannot parse such a large file content.


What happens when you try? You have to TellTheDetails(⇐click) because ItDoesntWorkIsUseless.(⇐click)
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also:
get the content from http://172.16.12.242/file/hex.txt path because i cannot give such a large content to coderanch forum


Nobody here can get that, because it's a private IP address.(⇐click)

But even if we could, we wouldn't. All we need to know is how big it is; we don't need to see the entire content.
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's huge ass data in one node then even SAXParsers will falter because the SAXParser operates at the level of the node. It will have to load the entire node in memory

 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan

For anyone to help you further, you must provide more information on what you have tried and what error you are getting.

If you had a problem with your plumbing and you rang a plumber and said "My water is not working", would you expect him to be able to fix the problem given that information?
 
Mohan rvscas
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, i gave the local ip address please change and refer the path http://122.183.130.242/file/hex.txt (this is public).

my problem :

In xml content there is a tag called field with the name field5. that has the long text. You can see the actual content in http://122.183.130.242/file/hex.txt url path.
i tried with out field5 tag its working fine but when i try with field5 tag the parser is not parsing actual content means it skips the reading and printing empty values

does my problem is meaning full? have any one understand my problem?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's huge ass data in one node then even SAXParsers will falter because the SAXParser operates at the level of the node. It will have to load the entire node in memory


Only true if an Element node has a huge number of attributes. A very unlikely situation.

Text nodes are read in buffer loads which is why the characters() method can be called with fragments of a Text node. This well known pitfall for beginning XML programmers may be the cause of the OP's confusion.

Bill
 
Paul Clapham
Sheriff
Pie
Posts: 20774
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohan rvscas wrote:i tried with out field5 tag its working fine but when i try with field5 tag the parser is not parsing actual content means it skips the reading and printing empty values

does my problem is meaning full? have any one understand my problem?


No, I don't understand your problem. You said the parser is printing empty values: this doesn't make any sense because the parser doesn't print anything. So perhaps you meant something else by that statement. Perhaps it's your code which is causing the problem. So why don't you post your code? Or actually, post the simplest possible version of it. An SSCCE (follow and read this link) would be the best thing to post.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic