[libxml++] parser problem



Hi!

I'm using libxml++ to parse an xml file like this:

.
.
xmlpp::DomParser       parser;
parser.set_validate(true);
parser.parse_file("example.xml");
.
.

The example.xml file looks like this:
<?xml version="1.0"?>
<!-- Example from XMLSchema recommendation 0 - primer at http://www.w3.org/TR/xmlschema-0/ -->
<purchaseOrder orderDate="1999-10-20">
   <shipTo country="US">
      <nme>Alice Smith</name>
.
.
.

and as you can see it contains an error at "<nme>Alice Smith</name>", that's fine.

Now.. when i'm running the program, i got this on the console:

example.xml:5: parser error : Opening and ending tag mismatch: nme line 5 and name
      <nme>Alice Smith</name>
                             ^

Which is - of course - OK, because it really contains errors, but i cannot control this error message with libxml++. I mean i got an exception whit this message: "Validity error:Validation failed: no DTD found !" but I can't get anything else. So what I want is that "opening and ending tag mismatch..." message do not appear on the console, instead I should control what should appear and what is not. Is there a simple way to do that in libxmlpp?

(I found a function in libxml called: xmlSetStructuredErrorFunc. When i use this function to set a callback, then it does exactly what i want. It does not send anything to the console instead it calls that callback function with the error message, and i can decide what i want to do that message.)




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]