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 05:15 PM 3/11/2002 +0000, you wrote:
please help asap..--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
I have a string say str, and I want to parse it.
Can I do:
DOMParser* parser ;
parser->parse(str_cstr());
thanks so much
Great minds discuss ideas, Average ones discuss events,
Small minds discuss people!!!!
**********Pankaj Bavishi************
10, Westgate Drive
Apt. #13,
Bohemia,
NY - 11716
>From: "Erik Rydgren"
>Reply-To:
>To:
>Subject: RE: select all nodes
>Date: Mon, 11 Mar 2002 17:25:50 +0100
>
>Use DOMString::transcode. Read the Xerces FAQ for common questions using it.
>Regards
>Erik Rydgren
>Mandarinen systems AB
>Sweden
>
>-----Original Message-----
>From: pankaj bavishi [mailto:[EMAIL PROTECTED]]
>Sent: den 11 mars 2002 17:05
>To: [EMAIL PROTECTED]
>Subject: RE: select all nodes
>
>
>
>
>
>
>how do I use:
>DOM_Document dummy.getElementsByTagName("hello");
>how should I pass ("hello")...it should be a DOMString.
>I can't do:
>DOMString st = "hello";
>please help
>
>
>
>Get your FREE download of MSN Explorer at http://explorer.msn.com.
>--------------------------------------------------------------------- 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]
>
Join the world’s largest e-mail service with MSN Hotmail. Click Here
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]