<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18112" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2010-11-05T05:06:28-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18112</id>

		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2010-11-05T05:06:28-04:00</updated>

		<published>2010-11-05T05:06:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94972#p94972</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94972#p94972"/>
		<title type="html"><![CDATA[looking for xml2dict]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94972#p94972"><![CDATA[
Hello there,<br><br>I'm currently working on a tcl which use an XML as datasource.<br>I've found an usefull procedure:<div class="codebox"><p>Code: </p><pre><code>proc xml2list xml {     regsub -all {&gt;\s*&lt;} [string trim $xml " \n\t&lt;&gt;"] "\} \{" xml     set xml [string map {&gt; "\} \{#text \{" &lt; "\}\} \{"}  $xml]     set res ""   ;# string to collect the result     set stack {} ;# track open tags     set rest {}     foreach item "{$xml}" { switch -regexp -- $item {    ^# {append res "{[lrange $item 0 end]} " ; #text item}    ^/ {regexp {/(.+)} $item -&gt; tagname ;# end tagset expected [lindex $stack end]if {$tagname!=$expected} {error "$item != $expected"}set stack [lrange $stack 0 end-1]append res "\}\} "  }    /$ { # singleton - start and end in one &lt;&gt; group       regexp {([^ ]+)( (.+))?/$} $item -&gt; tagname - rest       set rest [lrange [string map {= " "} $rest] 0 end]       append res "{$tagname [list $rest] {}} "    }    default {       set tagname [lindex $item 0] ;# start tag       set rest [lrange [string map {= " "} $item] 1 end]       lappend stack $tagname       append res "\{$tagname [list $rest] \{"    } } if {[llength $rest]%2} {error "att's not paired: $rest"}     }     if [llength $stack] {error "unresolved: $stack"}     string map {"\} \}" "\}\}"} [lindex $res 0] }</code></pre></div>Put I prefer working with dict than with list, so does anyone has an xml2dict procedure ?<br>I think I can do it, but I'm quite lazy <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Thanks by advance<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Fri Nov 05, 2010 5:06 am</p><hr />
]]></content>
	</entry>
	</feed>
