www.digitalmars.com         C & C++   DMDScript  

D - XML

reply "Matthew Wilson" <dmd synesis.com.au> writes:
Anything happening with D & XML?
Mar 24 2003
next sibling parent reply "Carlos Santander B." <carlos8294 msn.com> writes:
"Matthew Wilson" <dmd synesis.com.au> escribió en el mensaje
news:b5o7hv$nmt$1 digitaldaemon.com...
| Anything happening with D & XML?
|

You mean something like this?

"OddesE" <OddesE_XYZ hotmail.com> escribió en el mensaje
news:a27qo9$11p3$1 digitaldaemon.com...
| I have been reading some threads on using D in combination with HTML and
XML
| with great interest. Basically the ideas for XML were pretty basic, and
| Walter said that he did not know much about XML yet, but was interested. A
| lot of people said that XML, well, sucked, because it isn't easily human
| readable, but I would want these people and Walter to take a little while
| looking at some web sites about XML, and this website about programming:
|
| http://mindprod.com/scid.html
|
| Because if you combine XML with the ideas that Roedy Green talks about on
| that page, you might change your mind about XML. The longer I have been
| thinking about the XML threads I read, the more it seemed to me that
saving
| in any other format than XML made little sense!
| Here's why:
|
| Friends I have always write codeblocks like this:
|
| void Func(int iCount) {
|     for (int i=0; i<iCount; i++) {
|         printf ("Hello world.\n");
|     }
| }
|
| But I prefer:
|
| void Func(int iCount)
| {
|     for (int i=0; i<iCount; i++)
|     {
|         printf ("Hello world.\n");
|     }
| }
| or maybe:
|
| void Func(int iCount)
| {
|     for (int i=0; i<iCount; i++)
|         printf ("Hello world.\n");
| }
|
| All of these examples produce exactly the same program. They represent
| exactly the same data, they are only a different *view* on the data.
| Shouldn't changing the type of indentation for all source files you ever
| work with be as easy as changing one setting?
|
| Source files for programming languages like Java, C/C++ or D are plain
text
| files, that contain both layout and data, something we learned from HTML
| should be separated.
| Now imagine that beneath the surface the IDE would save the code above in
| XML like this:
|
| <?xml version="1.0">
| <Program>
|     <Module name="main">
|         <Function name="Func">
|             <Return>void</Return>
|             <Argument name="iCount">int</Argument>
|             <CodeBlock>
|                 <For>
|                     <ForInitializer>int i=0</ForInitializer>
|                     <ForUpdater>i<iCount</ForUpdater>
|                     <ForEvaluation>i<iCount</ForEvaluation>
|                     <CodeBlock>
|                         printf ("Hello world.\n");
|                     </CodeBlock>
|                 </For>
|             </CodeBlock>
|         </Function>
|     </Module>
| </Program>
|
| It looks very complex, but it contains the same information as the .d
file.
| Now it would be a breeze to change all kinds of layout settings to create
| another .d file with exactly the same source code, but with a different
| view on that source code.
|
| All you would need to do is make a XML specification for D code.
| You probably could find some people here on the newsgroup to deal with
| most of making such a specification, you would only have to make sure it
| was language compliant. Then everyone could use that spec to implement
| a tool to convert .d files to .xml files. And from .xml files you can go
| back
| to .html, .pdf, .doc or indeed other .d files without having to write
*any*
| software. You would only need to write an XSL
| stylesheet that containes the rules of making the conversion. All the .xml
| parsing and translation software can then be used.
|
| If I sound strange, check out that website I was referring to, and read
| something about XML, I think it will get clear what I mean and you
| will become enthousiastic about the idea.
|
| The XML code above was typed right into outlook from the top of
| my head and probably will contain errors. Also it is probably not a
| very good way to do this, but it illustrates the point.
| I think a good language designer who knows a little about XML
| could very easily make a smart and structured specification for saving
| D source code as XML code. I however am merely a humble
| programmer without a clue of the internals of compilers.  :)
| Read that web page, it will change the way you look at source code!
|
|

I haven't checked any of the sites provided on that thread or any other
related to the same topic, so I don't know if they're still working.

—————————————————————————
Carlos Santander
"Matthew Wilson" <dmd synesis.com.au> escribió en el mensaje
news:b5o7hv$nmt$1 digitaldaemon.com...
| Anything happening with D & XML?
|

You mean something like this?

"OddesE" <OddesE_XYZ hotmail.com> escribió en el mensaje
news:a27qo9$11p3$1 digitaldaemon.com...
| I have been reading some threads on using D in combination with HTML and
XML
| with great interest. Basically the ideas for XML were pretty basic, and
| Walter said that he did not know much about XML yet, but was interested. A
| lot of people said that XML, well, sucked, because it isn't easily human
| readable, but I would want these people and Walter to take a little while
| looking at some web sites about XML, and this website about programming:
|
| http://mindprod.com/scid.html
|
| Because if you combine XML with the ideas that Roedy Green talks about on
| that page, you might change your mind about XML. The longer I have been
| thinking about the XML threads I read, the more it seemed to me that
saving
| in any other format than XML made little sense!
| Here's why:
|
| Friends I have always write codeblocks like this:
|
| void Func(int iCount) {
|     for (int i=0; i<iCount; i++) {
|         printf ("Hello world.\n");
|     }
| }
|
| But I prefer:
|
| void Func(int iCount)
| {
|     for (int i=0; i<iCount; i++)
|     {
|         printf ("Hello world.\n");
|     }
| }
| or maybe:
|
| void Func(int iCount)
| {
|     for (int i=0; i<iCount; i++)
|         printf ("Hello world.\n");
| }
|
| All of these examples produce exactly the same program. They represent
| exactly the same data, they are only a different *view* on the data.
| Shouldn't changing the type of indentation for all source files you ever
| work with be as easy as changing one setting?
|
| Source files for programming languages like Java, C/C++ or D are plain
text
| files, that contain both layout and data, something we learned from HTML
| should be separated.
| Now imagine that beneath the surface the IDE would save the code above in
| XML like this:
|
| <?xml version="1.0">
| <Program>
|     <Module name="main">
|         <Function name="Func">
|             <Return>void</Return>
|             <Argument name="iCount">int</Argument>
|             <CodeBlock>
|                 <For>
|                     <ForInitializer>int i=0</ForInitializer>
|                     <ForUpdater>i<iCount</ForUpdater>
|                     <ForEvaluation>i<iCount</ForEvaluation>
|                     <CodeBlock>
|                         printf ("Hello world.\n");
|                     </CodeBlock>
|                 </For>
|             </CodeBlock>
|         </Function>
|     </Module>
| </Program>
|
| It looks very complex, but it contains the same information as the .d
file.
| Now it would be a breeze to change all kinds of layout settings to create
| another .d file with exactly the same source code, but with a different
| view on that source code.
|
| All you would need to do is make a XML specification for D code.
| You probably could find some people here on the newsgroup to deal with
| most of making such a specification, you would only have to make sure it
| was language compliant. Then everyone could use that spec to implement
| a tool to convert .d files to .xml files. And from .xml files you can go
| back
| to .html, .pdf, .doc or indeed other .d files without having to write
*any*
| software. You would only need to write an XSL
| stylesheet that containes the rules of making the conversion. All the .xml
| parsing and translation software can then be used.
|
| If I sound strange, check out that website I was referring to, and read
| something about XML, I think it will get clear what I mean and you
| will become enthousiastic about the idea.
|
| The XML code above was typed right into outlook from the top of
| my head and probably will contain errors. Also it is probably not a
| very good way to do this, but it illustrates the point.
| I think a good language designer who knows a little about XML
| could very easily make a smart and structured specification for saving
| D source code as XML code. I however am merely a humble
| programmer without a clue of the internals of compilers.  :)
| Read that web page, it will change the way you look at source code!
|
|

I haven't checked any of the sites provided on that thread or any other
related to the same topic, so I don't know if they're still working.

—————————————————————————
Carlos Santander
Mar 24 2003
parent reply "Matthew Wilson" <dmd synesis.com.au> writes:
Well, no I didn't, but that's very interesting, and would be a "very nice to
have" if anyone could get round to doing such a thing.

What I was asking was, is anyone working on any XML APIs for D, or has all
such work so far delegated to MSXML (or another COM) or libxml (or another
C) API?

"Carlos Santander B." <carlos8294 msn.com> wrote in message
news:b5o829$o28$1 digitaldaemon.com...
 "Matthew Wilson" <dmd synesis.com.au> escribió en el mensaje
 news:b5o7hv$nmt$1 digitaldaemon.com...
 | Anything happening with D & XML?
 |

 You mean something like this?

 "OddesE" <OddesE_XYZ hotmail.com> escribió en el mensaje
 news:a27qo9$11p3$1 digitaldaemon.com...
 | I have been reading some threads on using D in combination with HTML and
 XML
 | with great interest. Basically the ideas for XML were pretty basic, and
 | Walter said that he did not know much about XML yet, but was interested.
A
 | lot of people said that XML, well, sucked, because it isn't easily human
 | readable, but I would want these people and Walter to take a little
while
 | looking at some web sites about XML, and this website about programming:
 |
 | http://mindprod.com/scid.html
 |
 | Because if you combine XML with the ideas that Roedy Green talks about
on
 | that page, you might change your mind about XML. The longer I have been
 | thinking about the XML threads I read, the more it seemed to me that
 saving
 | in any other format than XML made little sense!
 | Here's why:
 |
 | Friends I have always write codeblocks like this:
 |
 | void Func(int iCount) {
 |     for (int i=0; i<iCount; i++) {
 |         printf ("Hello world.\n");
 |     }
 | }
 |
 | But I prefer:
 |
 | void Func(int iCount)
 | {
 |     for (int i=0; i<iCount; i++)
 |     {
 |         printf ("Hello world.\n");
 |     }
 | }
 | or maybe:
 |
 | void Func(int iCount)
 | {
 |     for (int i=0; i<iCount; i++)
 |         printf ("Hello world.\n");
 | }
 |
 | All of these examples produce exactly the same program. They represent
 | exactly the same data, they are only a different *view* on the data.
 | Shouldn't changing the type of indentation for all source files you ever
 | work with be as easy as changing one setting?
 |
 | Source files for programming languages like Java, C/C++ or D are plain
 text
 | files, that contain both layout and data, something we learned from HTML
 | should be separated.
 | Now imagine that beneath the surface the IDE would save the code above
in
 | XML like this:
 |
 | <?xml version="1.0">
 | <Program>
 |     <Module name="main">
 |         <Function name="Func">
 |             <Return>void</Return>
 |             <Argument name="iCount">int</Argument>
 |             <CodeBlock>
 |                 <For>
 |                     <ForInitializer>int i=0</ForInitializer>
 |                     <ForUpdater>i<iCount</ForUpdater>
 |                     <ForEvaluation>i<iCount</ForEvaluation>
 |                     <CodeBlock>
 |                         printf ("Hello world.\n");
 |                     </CodeBlock>
 |                 </For>
 |             </CodeBlock>
 |         </Function>
 |     </Module>
 | </Program>
 |
 | It looks very complex, but it contains the same information as the .d
 file.
 | Now it would be a breeze to change all kinds of layout settings to
create
 | another .d file with exactly the same source code, but with a different
 | view on that source code.
 |
 | All you would need to do is make a XML specification for D code.
 | You probably could find some people here on the newsgroup to deal with
 | most of making such a specification, you would only have to make sure it
 | was language compliant. Then everyone could use that spec to implement
 | a tool to convert .d files to .xml files. And from .xml files you can go
 | back
 | to .html, .pdf, .doc or indeed other .d files without having to write
 *any*
 | software. You would only need to write an XSL
 | stylesheet that containes the rules of making the conversion. All the
.xml
 | parsing and translation software can then be used.
 |
 | If I sound strange, check out that website I was referring to, and read
 | something about XML, I think it will get clear what I mean and you
 | will become enthousiastic about the idea.
 |
 | The XML code above was typed right into outlook from the top of
 | my head and probably will contain errors. Also it is probably not a
 | very good way to do this, but it illustrates the point.
 | I think a good language designer who knows a little about XML
 | could very easily make a smart and structured specification for saving
 | D source code as XML code. I however am merely a humble
 | programmer without a clue of the internals of compilers.  :)
 | Read that web page, it will change the way you look at source code!
 |
 |

 I haven't checked any of the sites provided on that thread or any other
 related to the same topic, so I don't know if they're still working.

 -------------------------
 Carlos Santander
 "Matthew Wilson" <dmd synesis.com.au> escribió en el mensaje
 news:b5o7hv$nmt$1 digitaldaemon.com...
 | Anything happening with D & XML?
 |

 You mean something like this?

 "OddesE" <OddesE_XYZ hotmail.com> escribió en el mensaje
 news:a27qo9$11p3$1 digitaldaemon.com...
 | I have been reading some threads on using D in combination with HTML and
 XML
 | with great interest. Basically the ideas for XML were pretty basic, and
 | Walter said that he did not know much about XML yet, but was interested.
A
 | lot of people said that XML, well, sucked, because it isn't easily human
 | readable, but I would want these people and Walter to take a little
while
 | looking at some web sites about XML, and this website about programming:
 |
 | http://mindprod.com/scid.html
 |
 | Because if you combine XML with the ideas that Roedy Green talks about
on
 | that page, you might change your mind about XML. The longer I have been
 | thinking about the XML threads I read, the more it seemed to me that
 saving
 | in any other format than XML made little sense!
 | Here's why:
 |
 | Friends I have always write codeblocks like this:
 |
 | void Func(int iCount) {
 |     for (int i=0; i<iCount; i++) {
 |         printf ("Hello world.\n");
 |     }
 | }
 |
 | But I prefer:
 |
 | void Func(int iCount)
 | {
 |     for (int i=0; i<iCount; i++)
 |     {
 |         printf ("Hello world.\n");
 |     }
 | }
 | or maybe:
 |
 | void Func(int iCount)
 | {
 |     for (int i=0; i<iCount; i++)
 |         printf ("Hello world.\n");
 | }
 |
 | All of these examples produce exactly the same program. They represent
 | exactly the same data, they are only a different *view* on the data.
 | Shouldn't changing the type of indentation for all source files you ever
 | work with be as easy as changing one setting?
 |
 | Source files for programming languages like Java, C/C++ or D are plain
 text
 | files, that contain both layout and data, something we learned from HTML
 | should be separated.
 | Now imagine that beneath the surface the IDE would save the code above
in
 | XML like this:
 |
 | <?xml version="1.0">
 | <Program>
 |     <Module name="main">
 |         <Function name="Func">
 |             <Return>void</Return>
 |             <Argument name="iCount">int</Argument>
 |             <CodeBlock>
 |                 <For>
 |                     <ForInitializer>int i=0</ForInitializer>
 |                     <ForUpdater>i<iCount</ForUpdater>
 |                     <ForEvaluation>i<iCount</ForEvaluation>
 |                     <CodeBlock>
 |                         printf ("Hello world.\n");
 |                     </CodeBlock>
 |                 </For>
 |             </CodeBlock>
 |         </Function>
 |     </Module>
 | </Program>
 |
 | It looks very complex, but it contains the same information as the .d
 file.
 | Now it would be a breeze to change all kinds of layout settings to
create
 | another .d file with exactly the same source code, but with a different
 | view on that source code.
 |
 | All you would need to do is make a XML specification for D code.
 | You probably could find some people here on the newsgroup to deal with
 | most of making such a specification, you would only have to make sure it
 | was language compliant. Then everyone could use that spec to implement
 | a tool to convert .d files to .xml files. And from .xml files you can go
 | back
 | to .html, .pdf, .doc or indeed other .d files without having to write
 *any*
 | software. You would only need to write an XSL
 | stylesheet that containes the rules of making the conversion. All the
.xml
 | parsing and translation software can then be used.
 |
 | If I sound strange, check out that website I was referring to, and read
 | something about XML, I think it will get clear what I mean and you
 | will become enthousiastic about the idea.
 |
 | The XML code above was typed right into outlook from the top of
 | my head and probably will contain errors. Also it is probably not a
 | very good way to do this, but it illustrates the point.
 | I think a good language designer who knows a little about XML
 | could very easily make a smart and structured specification for saving
 | D source code as XML code. I however am merely a humble
 | programmer without a clue of the internals of compilers.  :)
 | Read that web page, it will change the way you look at source code!
 |
 |

 I haven't checked any of the sites provided on that thread or any other
 related to the same topic, so I don't know if they're still working.

 -------------------------
 Carlos Santander
Mar 24 2003
parent reply Alix Pexton <Alix thedjournal.com> writes:
Matthew Wilson wrote:
 What I was asking was, is anyone working on any XML APIs for D, or has all
 such work so far delegated to MSXML (or another COM) or libxml (or another
 C) API?
I've been writing some code, but it is comming along very slowly. I started by rewriting the DOM Level 2 IDL interfaces into D interfaces, and renaming things that clashed with keywords. This you can have, but it isn't that usefull. I'm currently trying to write a generic implementation of the core interfaces, that uses all the best features of D, but I can't dedicate as much time to it as I'd like to... Alix... -- Alix Pexton Webmaster - http://www.theDjournal.com Alix theDjournal.com
Mar 25 2003
parent "Matthew Wilson" <dmd synesis.com.au> writes:
I'd like to take a look, but have little time atm also.

"Alix Pexton" <Alix thedjournal.com> wrote in message
news:b5q970$23st$1 digitaldaemon.com...
 Matthew Wilson wrote:
 What I was asking was, is anyone working on any XML APIs for D, or has
all
 such work so far delegated to MSXML (or another COM) or libxml (or
another
 C) API?
I've been writing some code, but it is comming along very slowly. I started by rewriting the DOM Level 2 IDL interfaces into D interfaces, and renaming things that clashed with keywords. This you can have, but it isn't that usefull. I'm currently trying to write a generic implementation of the core interfaces, that uses all the best features of D, but I can't dedicate as much time to it as I'd like to... Alix... -- Alix Pexton Webmaster - http://www.theDjournal.com Alix theDjournal.com
Mar 25 2003
prev sibling next sibling parent reply Benji Smith <Benji_member pathlink.com> writes:
I'm currently in the process of writing an XML parser in D. I'm implementing it
as a scanning stack-based finite-state-machine. The parser checks for
well-formedness, but I'm not implementing DTD validation quite yet. At the
moment, I'm using DOM Level 1 as a guideline, but I'm willing to deviate from
the standard (a little bit) where it makes sense.

Since my parser only makes a single pass over the xml file to do all of its work
(rather than a tokenization pass followed by a parsing pass followed by a
nesting pass), I expect that it will be very fast. I'm also implementing lots of
on/off switches that should allow a user to make the parse even faster (by
throwing agay comments or CDATA sections, etc).

It's coming along quite well, and I expect to have the parser working within a
few weeks. Like others have said, I don't have a lot of time, but this is my top
non-work project, so I devote a few hours here and there to it.

When I get it finished, I'm planning on posting the code to opend.org (under
LGPL or Apache license) and, at that point, I'll be looking for someone to help
implement DTD validation.

Is anyone interested in helping (preferably someone familiar with DTD
validation)?

--Benji


In article <b5o7hv$nmt$1 digitaldaemon.com>, Matthew Wilson says...
Anything happening with D & XML?
Mar 26 2003
next sibling parent "Matthew Wilson" <dmd synesis.com.au> writes:
Unfortunately I can't imagine having the time to help with impl, but I would
like to help testing by using it

"Benji Smith" <Benji_member pathlink.com> wrote in message
news:b5td2o$1cnb$1 digitaldaemon.com...
 I'm currently in the process of writing an XML parser in D. I'm
implementing it
 as a scanning stack-based finite-state-machine. The parser checks for
 well-formedness, but I'm not implementing DTD validation quite yet. At the
 moment, I'm using DOM Level 1 as a guideline, but I'm willing to deviate
from
 the standard (a little bit) where it makes sense.

 Since my parser only makes a single pass over the xml file to do all of
its work
 (rather than a tokenization pass followed by a parsing pass followed by a
 nesting pass), I expect that it will be very fast. I'm also implementing
lots of
 on/off switches that should allow a user to make the parse even faster (by
 throwing agay comments or CDATA sections, etc).

 It's coming along quite well, and I expect to have the parser working
within a
 few weeks. Like others have said, I don't have a lot of time, but this is
my top
 non-work project, so I devote a few hours here and there to it.

 When I get it finished, I'm planning on posting the code to opend.org
(under
 LGPL or Apache license) and, at that point, I'll be looking for someone to
help
 implement DTD validation.

 Is anyone interested in helping (preferably someone familiar with DTD
 validation)?

 --Benji


 In article <b5o7hv$nmt$1 digitaldaemon.com>, Matthew Wilson says...
Anything happening with D & XML?
Mar 27 2003
prev sibling parent reply Ilya Minkov <midiclub tiscali.de> writes:
Is there a significant advantage of writing a direct XML instead on an 
SGML parser?

What i mean, is that XML is a SGML subset. (is this true?) If so, it 
might be sane to write a SGML parser/generator/processor and then base 
an XML unit on it (wrap/inherit?). This would allow a broader usage for 
the underlying library, allowing to read/write legacy formats, like HTML 
and others existing. BTW, a feature like seen in Macromedia DreamWeaver, 
that it only changes the code that has been processed, and does not 
slurp in and spew out the whole document as some other libararies do 
would be really good. If you would like me to share some implementation 
ideas, or help with writing/debugging, write me. I don't have any 
XML-specific experience or thoughts though.

-i.

Benji Smith wrote:
 I'm currently in the process of writing an XML parser in D. I'm implementing it
 as a scanning stack-based finite-state-machine. The parser checks for
 well-formedness, but I'm not implementing DTD validation quite yet. At the
 moment, I'm using DOM Level 1 as a guideline, but I'm willing to deviate from
 the standard (a little bit) where it makes sense.
 
 Since my parser only makes a single pass over the xml file to do all of its
work
 (rather than a tokenization pass followed by a parsing pass followed by a
 nesting pass), I expect that it will be very fast. I'm also implementing lots
of
 on/off switches that should allow a user to make the parse even faster (by
 throwing agay comments or CDATA sections, etc).
 
 It's coming along quite well, and I expect to have the parser working within a
 few weeks. Like others have said, I don't have a lot of time, but this is my
top
 non-work project, so I devote a few hours here and there to it.
 
 When I get it finished, I'm planning on posting the code to opend.org (under
 LGPL or Apache license) and, at that point, I'll be looking for someone to help
 implement DTD validation.
 
 Is anyone interested in helping (preferably someone familiar with DTD
 validation)?
 
 --Benji
 
 
 In article <b5o7hv$nmt$1 digitaldaemon.com>, Matthew Wilson says...
 
Anything happening with D & XML?
Mar 28 2003
parent Alix Pexton <Alix thedjournal.com> writes:
Ilya Minkov wrote:
 Is there a significant advantage of writing a direct XML instead on an 
 SGML parser?
 
 What i mean, is that XML is a SGML subset. (is this true?) If so, it 
 might be sane to write a SGML parser/generator/processor and then base 
 an XML unit on it (wrap/inherit?). This would allow a broader usage for 
 the underlying library, allowing to read/write legacy formats, like HTML 
 and others existing. BTW, a feature like seen in Macromedia DreamWeaver, 
 that it only changes the code that has been processed, and does not 
 slurp in and spew out the whole document as some other libararies do 
 would be really good. If you would like me to share some implementation 
 ideas, or help with writing/debugging, write me. I don't have any 
 XML-specific experience or thoughts though.
 
SGML is huge, I wouldn't want to write a full parser for it, XML is sufficiently powerful and widely enough adopted to justify using it instead. As you say XML(1.0) is a subset of SGML which achieves simplicity through contraints such as well-formed-ness. I think is you want to process SGML from D, wrapping an existing library is the best way to go. To process HTML in D, I'd look at the code in mozilla that "corrects" HTML to make it into valid XHTML, a kind of preprocessor. The DOM implementation I've been working on will have (to use your terms) minimal slurping and spewing, primarily to minimise processing when using XPointers (by only reading enough of the source document to find the referenced text or elements). As such, the DOM datastructures are only created for parts of the document that are accessed (creating a document form scratch is like having no source document). The complex part comes from the editing, storing changes to the source document in the datastructure that youve created in such a way that the document can be written correctly when it is saved. I found recently that alot of the convienience methodes and data types I'd created are similar to parts of DOM Level 3 (which is not finished yet) and these help with implementation of the minimally digestive processor (to follow the theme of terminology) with new features such as mutation events... Alix... -- Alix Pexton Webmaster - http://www.theDjournal.com Alix theDjournal.com
Mar 28 2003
prev sibling parent Andy Friesen <andy ikagames.com> writes:
Matthew Wilson wrote:
 Anything happening with D & XML?
http://www.ikagames.com/andy/d/xmld.zip Nothing fancy, just a real simple DOM parser. No DTDs or anything fancy, though I'm rather pleased with the interface. The "adding" methods all return self references, so setting up document trees from scratch is pretty easy: node = new XmlNode("blah"); node.addChild(newNode("mynode") .setAttribute("x", "50") .setAttribute("y", 42) .setAttribute("label", "bob") .addChild( newNode("foobar") .setAttribute("thingie", "weefun") .addCdata("This is character <data>!") .addChild( newNode("man") .setAttribute("does", "this") .addCdata("ever rock") ) .addChild(newNode("baz")) ) ); (yes, this is taken to an extreme. don't actually do that) yields: <blah> <mynode x="50" y="42" label="bob"> <foobar thingie="weefun"> This is character &lt;data&gt;! <baz /> <man does="this"> ever rock </man> </foobar> </mynode> </blah>
May 04 2003