File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes DOM parsing using actual content of xml  file passed as a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "DOM parsing using actual content of xml  file passed as a String" Watch "DOM parsing using actual content of xml  file passed as a String" New topic
Author

DOM parsing using actual content of xml file passed as a String

shailendra shewale
Greenhorn

Joined: Jul 30, 2004
Posts: 10
Hi All ranchers

here is something we(i & my team member) found problem with.

we create DOM object as

DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

docBuilder.parse(
(new InputSource(new StringReader(strActualXMLFileContent)));

but it gives

com.caucho.xml.XmlParseException: stream:1: expected top element at `Element[QName[book] Attr[QName[vid] 200096f3-live] Attr[QName[cover] no]]

where,
strActualXMLFileContent is string containing actual XML file contents(& not file path)

and book,cover etc. are dom elements.

can somebody help please?

and also i will be thankful if i know is there any other methos to pass xml file 'contents' to a dom parser(other than what i have used)

shailendra shewale
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Could you post the exact contents of the String you're trying to parse?
Have you tried other parser implementations than Caucho's (for me, your current approach has always worked just fine)?


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
shailendra shewale
Greenhorn

Joined: Jul 30, 2004
Posts: 10
hi Lasse ,

Thank u for taking interest in my problem.But i cannot send the input xml that i gather in a string for it is really big xml file that takes IE5 more than 5-6 minutes to open.
If u still have something to add to ur reply please do that.
Thank you
shailendra shewale
shailendra shewale
Greenhorn

Joined: Jul 30, 2004
Posts: 10
and also there are company privacy reasons,please dont mind.
shailendra
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DOM parsing using actual content of xml file passed as a String