Re: multiple siblings, using tDOM to generate XML
- From: Ramon Ribó <ramsan@xxxxxxxxxxxxx>
- Date: Wed, 29 Nov 2006 23:06:59 +0100
Hello,
A simple way to generate XML is the following:
proc map { str } {
set mapTEXT2XML [list > ">" < "<" & "&" \" """ ' "'"]
return [string map $mapTEXT2XML $str]
}
set xml "<a><b>[map $mytext]</b>
<another_tag
>[map $more_text]</another_tag>
</a>"
set doc [dom parse $xml]
The only trick is to leave the newlines either inside the
construction <tag > or between tags that have no additional text.
Regards,
Ramon Ribó
En Wed, 29 Nov 2006 20:36:38 +0100, jkj <kevin@xxxxxxxxxx> escribió:
I'm wanting to use tDOM to generate an XML document but am having
difficulties with multiple siblings. These four lines are my desired
output:
<InformationURL>
<Name/>
<URL/>
</InformationURL>
...ok, I took the tutorial example and broke it down more step-by-step
and can see that the problem is a lack of newlines? - whatever that
translates into in Tcl. For example:
...a failure [title { } and description { } are on the same line]:
% $root appendFromScript {
channel {
title { } description { }
}
}
Invalid attribute name ' '
...the format that eventually passes:
% $root appendFromScript {
channel {
title { }
description { }
}
}
domNode0x8e678bc
...somehow I can't imagine that I have to insert newlines into a nested
set of these commands, so I would have thought that something like this
would work:
$root appendFromScript { [channel { [title { } ] [ description { } ] }
] }
...doesn't the [ command ] execute the command and return the value?
why the need for newlines?...
Thanks,
-Kevin
--
Compass Ing. y Sistemas Dr. Ramon Ribo
http://www.compassis.com ramsan@xxxxxxxxxxxxx
c/ Tuset, 8 7-2 tel. +34 93 218 19 89
08006 Barcelona, Spain fax. +34 93 396 97 46
.
- Follow-Ups:
- Re: multiple siblings, using tDOM to generate XML
- From: suchenwi
- Re: multiple siblings, using tDOM to generate XML
- References:
- Prev by Date: Re: multiple siblings, using tDOM to generate XML ... and eventually I arrive at a solution!
- Next by Date: Re: ANNOUCE: ActiveTcl 8.4.14.0 and 8.5.0.0b6 now available
- Previous by thread: Re: multiple siblings, using tDOM to generate XML
- Next by thread: Re: multiple siblings, using tDOM to generate XML
- Index(es):
Relevant Pages
|