void FromXmlElement(const CXmlElement* pElm)
void FromXmlElement(const CXmlElement* pElm, CXmlSerializationContext& context)
 PropertyDescription 
   Method Name FromXMLElement  
   Argument - pElm The Element containing the XML data to be de-serialized.  
   Argument - context The CXmlSerializationContext object controls the way in which XML is serialized/de-serialized. Its main role is to control the way in which validation is performed and which namespaces are output.
If this is not specified, the a default (CXmlSerializationContext::Default global static) instance of the class is used. If you are using several libraries generated from different schemas, or you want to change the way validation is performed for during the lifetime of the application or you are writing multithreaded code, then you should consider creating your own instance(s) of the CXmlSerializationContext.
If you are writing a multithreaded app it is highly recommended that you use a different instance of this class on each thread, as access to the static instance is not synchronized. Although read only operations to the static instance (CXmlSerializationContext::Default) of the class are thread safe, if the global instance CXmlSerializationContext::Default is modified, then this could potentially cause threading problems.
 
   Description De-Serializes the contents of an CXmlElement into the current object.  
    Remarks

This method will only load XML that complies with the XSD schema.
It will raise an exception if the XML is invalid.

Loading the data from a CXmlElement can be useful if you need to examine the data before loading it into a class. For example you may not know the kind of data that is contained in the file, so you may first need to examine the root element, and create the appropriate object to load the data into.

The root element in the XML held within lpszXMLIn must correspond to the class which this method is being called on. So you have a simple schema.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified">
  <xs:element name="Person">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="name" type="xs:string"/>
        <xs:element name="Address">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="HouseNumber" type="xs:string"/>
              <xs:element name="PostCode" type="xs:string"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>


This would cause 2 classes to be generated CPerson & CAddress.
So if you had the XML file test.xml, which contained.

<?xml version="1.0" encoding="UTF-8"?>
<Person>
  <name>Joe Blogs</name>
  <Address>
    <HouseNumber>15</HouseNumber>
    <PostCode>LS5 9PQ</PostCode>
  </Address>
</Person>


You would call FromXMLElement on a CPerson object ie

LtXmlLib16::CXmlDocument XmlDoc;
XmlDoc.Load("c:\\test.xml")
;
CPersonPtr spPerson = CPerson::CreateInstance();
spPerson->FromXMLElement(XmlDoc.GetDocumentElement())
;

Character encoding.
The underlying parser is expat version 1.95.6, as supports the following character encodings

  • UTF-8
  • UTF-16
  • UNICODE