Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

<?xml version='1.0' encoding='UTF-8'?> not first line of file

843834Jan 27 2010 — edited Jan 28 2010
There is an xml file whose contents are
    <!--  Comments -->
    <?xml version='1.0' encoding='UTF-8'?>
    <stuff>
    </stuff>
I'm not able to parse the file because the parser requires that
<?xml version='1.0' encoding='UTF-8'?>
is the first line of the file, whereas we have comments at the top of the file.

Is there a feature to ignore comments at the top of the file?

BTW, factory.setIgnoringComments(true) did not work.
      final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setIgnoringComments(true);
      DocumentBuilder builder;
      try
      {
         builder = factory.newDocumentBuilder();
         System.out.println(builder.getClass());
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 25 2010
Added on Jan 27 2010
2 comments
908 views