Re: Validate XML against xsdschema when parsing



first You have to have an schema.xsd file.
then I think you have to do something like this:

                string schema = "schema.xsd"
SchemaValidator validator(schema);

DomParser parser;
parser.set_throw_messages(true);

               string xml = "file.xml"

parser.parse_file(xml);

validator.validate(parser.get_document());

                xmlpp::Node* rootNode = parser.get_document()->get_root_node();

                ....

and continue parsing.

I haven't test it

regards


On Fri, Feb 5, 2016 at 7:41 PM, Lingxiao Jia <Lingxiao Jia arm com> wrote:

Hello all,

 

We have a project that wants to use libxml++ to parse and validate xml files. Originally we use DTD to validate, but recently we want to switch to XML Schema.

However, I cannot find a way to do validation with parsing just as we did with DTD by calling set_validate().

Is there someone who knows if it is possible to do it simply, or I have to create a XsdValidator object separately to validate the XML file?

 

Best regards,

Lingxiao

 

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

_______________________________________________
libxmlplusplus-list mailing list
libxmlplusplus-list gnome org
https://mail.gnome.org/mailman/listinfo/libxmlplusplus-list




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