Carlo,
This code snippet demonstrates basic string and file parsing.
const bool LoadFromStream = true; // Set to false for file i/o
const std::string MyFileName ("C:\TEMP\TEST.XML");
const std::string 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.c_str());
else
{
MemBufIS = new MemBufInputSource(
(const XMLByte*)MyStream.c_str(), // Stream pointer
MyStream.size()+ 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;
This example uses STL string references. Traditional C-style strings can
be used as well by substituting char*, pointers, and strlen() for
std::string, c_str() and size() respectively.
HTH,
Don
At 10:44 AM 4/19/2002 -0700, you wrote:
>I've noticed that the API documentation and samples are geared towards
>parsing XML files. Is there a way to parse XML documents that are in the
>form of char strings existing in cached memory? Generaly these are data
>that are processed as soon as read from the socket(TCP/IP). Any help will
>be greatly appreciated.
>
>Thanks,
>
>Carlo
>[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]