This ought to get you started. While this code snippet was not compiled
and tested, it was extracted from one of my projects. It demonstrates
loading from either a file or a stream.
const bool LoadFromStream = true; // Set to false for file i/o
const char *MyFileName = "C:\TEMP\TEST.XML";
const char *MyStream = "<?xml version='1.0' encoding='utf-8' ?><TAG>My
Data</TAG>";
char *BufferID = NULL;
MemBufInputSource *MemBufIS = NULL;
DOMParser *Parser = new DOMParser;
Parser->setCreateEntityReferenceNodes(false);
Parser->setDoNamespaces(false);
Parser->setDoSchema(false);
Parser->setDoValidation(false);
Parser->setToCreateXMLDeclTypeNode(true);
Parser->setValidationScheme(false);
if (!LoadFromStream)
Parser->parse(MyFileName);
else
{
MemBufIS = new MemBufInputSource(
(const XMLByte*)MyStream, // Stream pointer
::strlen(MyStream) + 1, // Byte (not character) count
&BufferID, // Buffer ID (becomes
System ID)
false); // Copy (not adopt)
caller's buffer
if (MemBufIS == NULL)
{
// Handle errors here
}
Parser->parse(*MemBufIS);
} // End if (LoadFromStream)
DOM_Node Root = Parser->getDocument();
DOM_Document Document = Parser->getDocument();
if (MemBufIS != NULL)
delete MemBufIS;
HTH,
Don
At 02:34 PM 1/16/2002 -0800, you wrote:
>Can I parse an XML document that is stored in a char *? If so, does
>anyone have an example of setting up the parser to do it? Currently my
>application parses from a document.
>
>Thanks,
>Drew
>
>
>**********************************************************************
>This email and any files transmitted with it are confidential and
>intended solely for the use of the individual or entity to whom they
>are addressed. If you have received this email in error please notify
>the TenFold Postmaster ([EMAIL PROTECTED]).
>**********************************************************************
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]