[xsd-users] Handling part of an XML document
Boris Kolpackov
boris at codesynthesis.com
Wed Nov 21 03:58:52 EST 2007
Hi Nicholas,
Nicholas Xu <xunich at gmail.com> writes:
> Can xsd support to parse or serialize part of an XML document (let's
> say, a sub-element)?
Yes, you can parse/serialize XML fragments that correspond to individual
schema types. For that, however, you will need to set up the XML-to-DOM
(for parsing) and DOM-to-XML (for serialization) stages yourself. Then
you can instantiate an object model type from DOMElement or DOMAttr
as well as serialize an instance of an object model type to DOMElement
or DOMAttr.
For more details on how to implement this kind of parsing, see Q 2.4 and
2.5 in the C++/Tree Mapping FAQ[1] as well as the multiroot example in
examples/cxx/tree/.
For serialization, see Q 3.1 and 3.2 in the FAQ[1]. Once you have an
object model node and DOMElement, you can perform serialization by
using the serialization operator:
const SomeType& x = ... // Object model instance to serialize.
DOMElement& e = ... // DOM element to serialize to.
e << x;
[1] http://wiki.codesynthesis.com/Tree/FAQ
Boris
More information about the xsd-users
mailing list