You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Rupanu Ranjaneswar <ru...@yahoo.com> on 2009/07/24 10:56:33 UTC
How to create DOMDocument from XML string.
Hi , I was able to resolve the previous issue searching in the mail archieves.However UTF-16 to UTF-8 transcoding doesn't seem to be working.
I have a XMl string (whole content of an XML file), please tell me how do i create a DOMDocument out of it. parse function of XercesDOMParser doesn't seem to be parsing an XML string..
regards rupanu.
RE: How to create DOMDocument from XML string.
Posted by Rupanu Ranjaneswar <ru...@yahoo.com>.
Thanks very much for your response.I found another way of doing it and it works well..
DOMLSInput* input = pImplement->createLSInput();input->setStringData(str);DOMLSParser *domparser = pImplement->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0); DOMDocument* domdoc = domparser->parse(input);
///////////////////////////
--- On Fri, 7/24/09, John Lilley <jl...@datalever.com> wrote:
From: John Lilley <jl...@datalever.com>
Subject: RE: How to create DOMDocument from XML string.
To: "c-users@xerces.apache.org" <c-...@xerces.apache.org>
Date: Friday, July 24, 2009, 9:28 AM
Have you tried something like this:
XN::XercesDOMParser parser;
// Adapt buffer to a form that can be read by the parser.
XN::MemBufInputSource inputSource(
(const XMLByte *)str,
(int)strlen(str),
"system" // fake "system ID"
);
parser.parse(inputSource);
doc = parser.adoptDocument();
-----Original Message-----
From: Rupanu Ranjaneswar [mailto:rupanu_pal@yahoo.com]
Sent: Friday, July 24, 2009 2:57 AM
To: c-users@xerces.apache.org
Subject: How to create DOMDocument from XML string.
Hi , I was able to resolve the previous issue searching in the mail archieves.However UTF-16 to UTF-8 transcoding doesn't seem to be working.
I have a XMl string (whole content of an XML file), please tell me how do i create a DOMDocument out of it. parse function of XercesDOMParser doesn't seem to be parsing an XML string..
regards rupanu.
RE: How to create DOMDocument from XML string.
Posted by John Lilley <jl...@datalever.com>.
Have you tried something like this:
XN::XercesDOMParser parser;
// Adapt buffer to a form that can be read by the parser.
XN::MemBufInputSource inputSource(
(const XMLByte *)str,
(int)strlen(str),
"system" // fake "system ID"
);
parser.parse(inputSource);
doc = parser.adoptDocument();
-----Original Message-----
From: Rupanu Ranjaneswar [mailto:rupanu_pal@yahoo.com]
Sent: Friday, July 24, 2009 2:57 AM
To: c-users@xerces.apache.org
Subject: How to create DOMDocument from XML string.
Hi , I was able to resolve the previous issue searching in the mail archieves.However UTF-16 to UTF-8 transcoding doesn't seem to be working.
I have a XMl string (whole content of an XML file), please tell me how do i create a DOMDocument out of it. parse function of XercesDOMParser doesn't seem to be parsing an XML string..
regards rupanu.
Re: How to create DOMDocument from XML string.
Posted by Rupanu Ranjaneswar <ru...@yahoo.com>.
For encoding issue this is what i did..
DOMLSOutput* output = pImplement->createLSOutput(); output->setEncoding(L"UTF-8");XMLFormatTarget* pTarget = new LocalFileFormatTarget("DOMString1.xml"); output->setByteStream(pTarget); pSerializer->write(pDOMDocument,output);
thanks & regardsrupanu
--- On Fri, 7/24/09, Alberto Massari <am...@datadirect.com> wrote:
From: Alberto Massari <am...@datadirect.com>
Subject: Re: How to create DOMDocument from XML string.
To: c-users@xerces.apache.org
Date: Friday, July 24, 2009, 5:18 AM
See the MemParse example for an example on how to parse an XML string, and DOMPrint to see how to force a specific encoding when saving to a file.
Alberto
Rupanu Ranjaneswar wrote:
> Hi , I was able to resolve the previous issue searching in the mail archieves.However UTF-16 to UTF-8 transcoding doesn't seem to be working.
> I have a XMl string (whole content of an XML file), please tell me how do i create a DOMDocument out of it. parse function of XercesDOMParser doesn't seem to be parsing an XML string..
>
> regards rupanu.
>
>
>
Re: How to create DOMDocument from XML string.
Posted by Alberto Massari <am...@datadirect.com>.
See the MemParse example for an example on how to parse an XML string,
and DOMPrint to see how to force a specific encoding when saving to a file.
Alberto
Rupanu Ranjaneswar wrote:
> Hi , I was able to resolve the previous issue searching in the mail archieves.However UTF-16 to UTF-8 transcoding doesn't seem to be working.
> I have a XMl string (whole content of an XML file), please tell me how do i create a DOMDocument out of it. parse function of XercesDOMParser doesn't seem to be parsing an XML string..
>
> regards rupanu.
>
>
>
>