• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Exception while parsing XML document  RSS feed

 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,
I am constantly getting this error message while parsing XML document:

Google research says it happends if there's space before the starting '<' character,but I don't see any space in my XML document,please help.Here's my code:


And here's my parsing code fragment:
 
Sheriff
Posts: 23712
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will get that error if you have anything before the XML prolog, which is the <?xml ... ?> part.

I don't quite get all that code you posted. None of it is the XML document, which is the first thing I would have looked at. But my guess is that you have posted something that generates XML, something that posts it to an HTTP URL, and something that runs on the server and tries to parse the posted XML. Have I disentangled the post correctly?

If I have, then clearly your XML document looks likewhich, as I mentioned at the beginning, is not well-formed XML. If you want the XML you generate to include a DOCTYPE, then you should just tell the Transformer to include one. Like this:
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,
Your interpretation was exact.So,rite now as you said the xml is formed in this way:

I add "<!DOCTYPE SubmitSMS>" to the string,so if i remove that part i get:

But how to add "<!DOCTYPE SubmitSMS>" this after that i.e:


Because this does not works:

Any help would be appreciated.
thanks
[ May 09, 2006: Message edited by: jas oberai ]
 
Paul Clapham
Sheriff
Posts: 23712
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you should stop fighting against the system and work with it. Start by trying something simple:and see what that does.
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul,
that doesn't displays anything,but if i do this:

I get this:

But I want just this..thats it:

Thanks
 
Paul Clapham
Sheriff
Posts: 23712
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you want that for? The XML Recommendation says

"Note that it is possible to construct a well-formed document containing a doctypedecl that neither points to an external subset nor contains an internal subset."

Which is what you are trying to do there, but what is the point of it? Seems to me that just leaving it out would produce XML that is functionally equivalent.
 
Jas Oberai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanls again Pual,
I have a specified format given to me by a gateway provider and its like this:

So,for that purpose I need to create a xml similar to that from my java code and post it on their gateway and then only they would parse it.

But I don't know how to add that <!DOCTYPE SubmitSMS> thing,so I created XML and just added that part to the start of the String.But doing that caused the XML formed in this manner:

and that was what was causing the initial problem,and it failed during parsing.So,did you get any clues,can u help me now.
Thanks for all your help,really appreciate it and waiting for your answer.
 
Paul Clapham
Sheriff
Posts: 23712
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer was "Seems to me that just leaving it out would produce XML that is functionally equivalent." Did you try that?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!