Creation of XML documents

Richard Anderson RJA at arpsolutions.demon.co.uk
Fri Nov 13 15:02:00 GMT 1998


> I would like to have a 'library' to which the application developer
> could say 'using this DTD please
> instantiate a XML document and help me to fill it in'.

I've got a C++ toolkit that is under development that sort of mets these
requirements. It has a SAX+DOM interface.   ( The COM variant will follow
very shortly for use in VB etc )

Using the SAX interface you can build a 'template' DOM and then fill in the
missing bits.

The toolkit has *no* dependancies on MSIE etc.

Heres some sample code for creating an XML EMAIL:

************ CODE SECTION START ****************

pDoc = pDOMAPI->createDocument();
 pRootElement = pDoc->createElement( L"EMAIL" );
pFrom = pDoc->createElement( L"From" );
 pRootElement->appendChild( pFrom );
pFrom->setAttribute( L"Priority", L"High" );
 pFrom->setAttribute( L"DeliveryReceipt", L"Yes" );
 pFrom->setAttribute( L"ReturnReceipt", L"Yes" );

pText = pDoc->createTextNode( L"RJA at arpsolutions.demon.co.uk" );
pFrom->appendChild( pText );

pTo = pDoc->createElement( L"To" );
pRootElement->appendChild( pTo );
pText = pDoc->createTextNode( L"enquires at arpsolutions.demon.co.uk" );
pTo->appendChild( pText );

pSubject = pDoc->createElement( L"Subject" );
pRootElement->appendChild( pSubject );
pText = pDoc->createTextNode( L"XML/DOM/SAX C++ Toolkit" );
pSubject->appendChild( pText );

pComment = pDoc->createComment(L"Main body of Email follows");
pRootElement->appendChild( pComment );
pBody = pDoc->createElement( L"Body" );
pRootElement->appendChild( pBody );

pText = pDoc->createTextNode( L"Seems OK so far." );
pBody->appendChild( pText );

pText = pDoc->createTextNode( L"I'll have to try harder to break it." );
pBody->appendChild( pText );

pPI = pDoc->createProcessingInstruction(L"PI",
                                          L"That's all folks!" );

pCC = pDoc->createElement( L"CC" );
pText = pDoc->createTextNode( L"xml_toolkit at arpsolutions.demon.co.uk" );
pCC->insertBefore( pText, NULL );
pRootElement->insertBefore( pCC,pTo );

CStdioWideStream stream;
pDOMAPI->writeXML( pRootElement, &stream );

*********** CODE SECTION END ***************

If your interested I can send you the C++ alpha toolkit.

Regards,

Richard.

***********************************************
* E-Mail  mailto:RJA at arpsolutions.demon.co.uk *
* WEB     http://www.arpsolutions.demon.co.uk *
***********************************************



xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list