BOM? org.xml.sax.SAXParseException: Content is not allowed in prolog.

I read in a SOAP http response which is an xml string and try to build a DOM object out of it for parsing but I think a BOM (byte order mark) is causiing this exception...


2006-08-24 18:21:28,894 INFO  [STDOUT] Exception: Content is not allowed in prolog.
2006-08-24 18:21:28,904 INFO  [STDOUT] org.xml.sax.SAXParseException: Content is not allowed in prolog.
2006-08-24 18:21:28,904 INFO  [STDOUT]       at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
2006-08-24 18:21:28,904 INFO  [STDOUT]       at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
2006-08-24 18:21:28,904 INFO  [STDOUT]       at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)


I googled around for a solution but no success? Anyone now how to strip away a BOM?



LVL 1
defa0009Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Try something like:


try {
      PushbackReader r = new PushbackReader(new InputStreamReader(new URL(url).openStream()));
      int ch = -1;
      // scan for the < character
      while((ch = r.read()) != '<');
      if( ch == '<')
            r.unread('<') ;
      builder.parse(new InputSource(r));
      System.out.println("ok");
} catch (Exception e) {
      e.printStackTrace();
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
defa0009Author Commented:
Thanks..
0
CEHJCommented:
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.