[XML-SIG] parsing CDATA section

Dieter Maurer dieter at handshake.de
Thu Dec 29 19:22:05 CET 2005


Ankit Rastogi wrote at 2005-12-28 08:02 -0800:
>I am having problem with parsing CDATA section. I am using PyXml and minidom for parsing the xml document. 
>  My motive is to get the data back in the same format in one string as it is writen in xml file. Here is the sample:
>  --
>  <StateChg>
>      <![CDATA[
>                check.. its cdata section
>  
>                 all data is printed in it s format
>                 ]]>
><StateChg>
>  --
>  put when I print all its childs using:
>  ---
>   print StChg.childNodes  #StChg. is instance to <StateChg> element
>  --
>  It gives following output
>  --
>  [<DOM Text node "\n">, <DOM Text node "\t\t\t\t \t">, <DOM Text node "\n">, <DOM Text node "\t\t\t\t\t chec...">, <DOM Text node "\n">, <DOM Text node "\t\t\t\t\t all ...">, <DOM Text node "\n">, <DOM Text node "\t\t\t\t\t ">, <DOM Text node "\n">, <DOM Text node "\t\t\t\t\t">]
>--

You might be interested in the "normalize" DOM method: it combined
adjacent text nodes into a single one.


-- 
Dieter


More information about the XML-SIG mailing list