aspose file tools*
The moose likes Java in General and the fly likes XML parsing using DOMParser gets no result unless xmlns is removed?! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "XML parsing using DOMParser gets no result unless xmlns is removed?!" Watch "XML parsing using DOMParser gets no result unless xmlns is removed?!" New topic
Author

XML parsing using DOMParser gets no result unless xmlns is removed?!

Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Hi, I was trying to parse this file - http://www.pubmedcentral.nih.gov/oai/oai.cgi?verb=GetRecord&metadataPrefix=pmc&identifier=oai:pubmedcentral.nih.gov:32301 - using the following code -



Here, at "section nodes," I expect an output of 1, because there is one node in the xml that starts with "article." Instead, I have been getting 0. So I downloaded the file and tweaked around a little, and found that when I get rid of the xmlns=".." declaration in tags "OAI-PMH" and "article," the parser runs fine.

Is there any way of turning off the namespace awareness? Or is there any way the code can be modified to fix the problem? Thanks a lot for any help.
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
Hey guys, found a fix! Inserted this line after line 04.

parser.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, false);

2.5 hours well wasted!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XML parsing using DOMParser gets no result unless xmlns is removed?!