 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
DRS Guest
|
Posted: Mon May 14, 2007 10:54 pm Post subject: How to save each field as an element? |
|
|
Using IXMLDocument from XMLDoc it's easy enough to generate XML like this:
- <root>
<node attr1="hello" attr2="world" />
</root>
However, this is not what I want. How do I generate XML like this:
- <root>
<node id="XXX">
<attr1>"hello"</attr1>
<attr2>"world"</aatr2>
</node>
<node id="YYY">
<attr1>"good-bye"</attr1>
<attr2>"cruel world"</aatr2>
</node>
</root> |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon May 14, 2007 11:34 pm Post subject: Re: How to save each field as an element? |
|
|
"DRS" <drs (AT) removethis (DOT) ihug.com.au> wrote in message
news:4648a2df (AT) newsgroups (DOT) borland.com...
| Quote: | How do I generate XML like this:
|
You need to use the IXMLNode.AddChild() method instead of the
Attributes list, ie:
var
Root: IXMLNode;
Node: IXMLNode;
Root := XMLDoc.CreateElement('root', '');
XMLDoc.DocumentElement := root;
Node := Root.AddChild('node');
Node.Attributes['id'] := 'XXX';
Node.AddChild('attr1').Text := 'hello';
Node.AddChild('attr2').Text := 'world';
Node := Root.AddChild('node');
Node.Attributes['id'] := 'YYY';
Node.AddChild('attr1').Text := 'good-bye';
Node.AddChild('attr2').Text := 'cruel world';
Gambit |
|
| Back to top |
|
 |
DRS Guest
|
Posted: Tue May 15, 2007 1:57 am Post subject: Re: How to save each field as an element? |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:4648ad48$1 (AT) newsgroups (DOT) borland.com
| Quote: | "DRS" <drs (AT) removethis (DOT) ihug.com.au> wrote in message
news:4648a2df (AT) newsgroups (DOT) borland.com...
How do I generate XML like this:
You need to use the IXMLNode.AddChild() method instead of the
Attributes list, ie:
var
Root: IXMLNode;
Node: IXMLNode;
Root := XMLDoc.CreateElement('root', '');
XMLDoc.DocumentElement := root;
Node := Root.AddChild('node');
Node.Attributes['id'] := 'XXX';
Node.AddChild('attr1').Text := 'hello';
Node.AddChild('attr2').Text := 'world';
Node := Root.AddChild('node');
Node.Attributes['id'] := 'YYY';
Node.AddChild('attr1').Text := 'good-bye';
Node.AddChild('attr2').Text := 'cruel world';
|
Very nice. And how would you parse it? |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 15, 2007 4:12 am Post subject: Re: How to save each field as an element? |
|
|
"DRS" <drs (AT) removethis (DOT) ihug.com.au> wrote in message
news:4648cda3 (AT) newsgroups (DOT) borland.com...
| Quote: | Very nice. And how would you parse it?
|
Use the IXMLNode's ChildNodes list. Please read the documentation.
IXMLDocument and IXMLNode are fully described.
Gambit |
|
| Back to top |
|
 |
DRS Guest
|
Posted: Tue May 15, 2007 8:13 am Post subject: Re: How to save each field as an element? |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:4648ee92$1 (AT) newsgroups (DOT) borland.com
| Quote: | "DRS" <drs (AT) removethis (DOT) ihug.com.au> wrote in message
news:4648cda3 (AT) newsgroups (DOT) borland.com...
Very nice. And how would you parse it?
Use the IXMLNode's ChildNodes list. Please read the documentation.
IXMLDocument and IXMLNode are fully described.
|
Not in D6 Pro they're not. As I said earlier, I'm flying in the dark. 99%
of the XML documentation was removed by Borland and the other 1% says
"Enterprise Support" even though Borland did in fact supply all the XML?.pas
files *except* for XMLIntf.pas which actually exposes the interfaces. I'm
relying heavily on Googling for code snippets and bits and pieces from
CodeCentral but they're far from complete as most simply assume you have the
documentation. It's incredibly time consuming and wasteful. Since
XMLIntf.pas is missing, although XMLIntf.dcu is present, without code
completion I wouldn't have been able to get as far as I have, although even
code completion doesn't give me everything since there's no way I can, for
example, find the possible values for something like TXMLDocOptions as Find
Declaration naturally fails.
What I need is a tutorial program like the one I wrote some years ago for
ADOX (http://cc.codegear.com/Item/15292). |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 15, 2007 3:18 pm Post subject: Re: How to save each field as an element? |
|
|
"DRS" <drs (AT) removethis (DOT) ihug.com.au> wrote in message
news:4649441e (AT) newsgroups (DOT) borland.com...
| Quote: | Borland did in fact supply all the XML?.pas files *except* for
XMLIntf.pas which actually exposes the interfaces.
|
I have posted XMLIntf.pas to the "borland.public.attachments"
newsgroup for you.
Gambit |
|
| Back to top |
|
 |
DRS Guest
|
Posted: Thu May 17, 2007 8:13 am Post subject: Re: How to save each field as an element? |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote in message
news:46498aa9 (AT) newsgroups (DOT) borland.com
| Quote: | "DRS" <drs (AT) removethis (DOT) ihug.com.au> wrote in message
news:4649441e (AT) newsgroups (DOT) borland.com...
Borland did in fact supply all the XML?.pas files *except* for
XMLIntf.pas which actually exposes the interfaces.
I have posted XMLIntf.pas to the "borland.public.attachments"
newsgroup for you.
|
Much appreciated. |
|
| Back to top |
|
 |
Powered by phpBB © 2001, 2006 phpBB Group .
|