xml quote attribute value in tcl -


how can "convert" non valid xml (i.e. attrbutes not quoted) valid xml, i.e. convert a=b attribute a="b".

for example such xml file:

<top> <name name='name' /> <group number=1> <member name='name1' test='test1' l=100/> </group> </top> 

desire output be:

<top> <name name='name' /> <group number="1"> <member name='name1' test='test1' l="100"/> </group> </top>" 

i know tdom package, has -html option. package should use dom, xml file attribute must quoted.

that's not valid xml document, can't use xml processor tdom this. instead, have nasty regular expressions , hope best:

set inputdocument "…"  regsub -all {(\w+)=(\w+)} $inputdocument {\1="\2"} outputdocument  puts $outputdocument 

this isn't honest, right thing in case. possible put more effort in , ensure transformation applied within elements , not in bodies well, if it's enough real data it's enough. (getting such transformations right quite hard since input document not xml; knows other nasties lying in wait inside in general?)


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -