You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Rocky Raccoon <rr...@bigfoot.com> on 2000/05/03 01:09:04 UTC
Create an XML File
I need to create an XML File in memory.
For eg.
Create the Root Element. Add Children to it. Add Attributes etc.
Once I am finished, I need this whole XML as a string.
How do I go about doing this ?
I looked the CreateDomDocument example.
That seems to work But can't figure out any way to get the whole
thing as a string once I have created the XML
Also, the docs seem to say that most of the methods used are
experimental.
Is there a standard way to do all this ? Any other example I can look
at.
Re: Create an XML File
Posted by Berin Loritsch <bl...@infoplanning.com>.
As far as the first part of your problem goes, you can serialize it to
a StringWriter, and when your done use the toString() method.
Technically, the document node has a toString() method as well,
but it doesn't preserve the DOCTYPE information properly--at
least in my experience. (oops, that was Java....)
As far as the second part of your problem goes, I am in the same boat.
I am using the DOM2 API, which will allow me to create a document,
but having problems setting the DOCTYPE correctly. It appears that
you have to do things somewhat backward: create a DocType, and
then create a document with the DocType passed to the constructor.
Can anyone clarify this issue?
No RTFM responses please, because the manual does not cover this
properly. The API docs (JavaDocs) need to be expanded to include
this information--much like the java.text.SimpleDateFormat and
java.text.DateFormat docs are configured. The FAQs do not cover
this adequately either. In fact, the only information I have been able
to find have been in the mailing lists, and then the details are sketchy
and the attitude is condescending.
Rocky Raccoon wrote:
> I need to create an XML File in memory.
> For eg.
> Create the Root Element. Add Children to it. Add Attributes etc.
>
> Once I am finished, I need this whole XML as a string.
>
> How do I go about doing this ?
> I looked the CreateDomDocument example.
> That seems to work But can't figure out any way to get the whole
> thing as a string once I have created the XML
> Also, the docs seem to say that most of the methods used are
> experimental.
> Is there a standard way to do all this ? Any other example I can look
> at.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
RE: Create an XML File
Posted by Ward Cannon <wa...@creativeplanet.com>.
Hi Mr. Raccon,
have a look at the StrX class in one of the samples.
Or actually the DOMString class has a transcode method
to convert to char * form for the default code page.
Hope this helps.
Ward
-----Original Message-----
From: Rocky Raccoon [mailto:rrocky@bigfoot.com]
Sent: Tuesday, May 02, 2000 4:09 PM
To: xerces-c-dev@xml.apache.org
Subject: Create an XML File
I need to create an XML File in memory.
For eg.
Create the Root Element. Add Children to it. Add Attributes etc.
Once I am finished, I need this whole XML as a string.
How do I go about doing this ?
I looked the CreateDomDocument example.
That seems to work But can't figure out any way to get the whole
thing as a string once I have created the XML
Also, the docs seem to say that most of the methods used are
experimental.
Is there a standard way to do all this ? Any other example I can look
at.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org