Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How can I parse an invalid XML file with DOM API ?

Posted on 2003-02-18
3
Medium Priority
?
515 Views
Last Modified: 2011-10-03
[Fatal Error] StatisticsLog_MIEP_20030129000057760.xml:111:741426: An invalid XML character (Unicode: 0x2) was found in the element content of the document.
java.lang.NullPointerException
     at com.MASP.report.wappie.MIEPlogs_Parser.findMatchedEDPID(MIEPlogs_Parser.java:57)
     at com.MASP.report.wappie.MIEPlogs_Parser.main(MIEPlogs_Parser.java:101)
Exception in thread "main"

This invalid XML file is too big,I can not find the wrong place.I use standard DOM API to parse this file.I want to know wheather I can pass througth when I run this program.
if can,could you tell me what should I do to my program.My program is as follows.


  protected DocumentBuilderFactory factory ;
  protected DocumentBuilder builder ;
  protected Document document ;
  try {
            factory =DocumentBuilderFactory.newInstance();
            builder = factory.newDocumentBuilder();
        }catch (FactoryConfigurationError e) {
            // unable to get a document builder factory
        }catch (ParserConfigurationException e) {
            // parser was unable to be configured
        }




0
Comment
Question by:wuchunzhong
1 Comment
 
LVL 27

Accepted Solution

by:
BigRat earned 800 total points
ID: 7981099
This is an annoyance since XML is VERY strict about what constitutes a character. Basically anything below hex 20 which is nt CR nor LF is invalid.

I can only suggest that you "clean up" the file by substituting such characters with, say, hex BF (inverted question), with perhaps a bit of script (awk? perl? regex?) depending on the encoding of the file.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question