indent in xml

sdf wqh-2 at 263.net
Wed Aug 1 23:32:20 EDT 2001


I want to get the first child node of one node,but because of the indent 
problem(I think so),the first two child is not what i want ,but the '\n' 
and '',the xml file is:
<books>
  book>
  <title>Pierre: The Ambiguities</title> 
  <author>Herman Melville</author> 
  <price>9.99</price> 
  </book>
  <book>
   <title>The Republic</title> 
  <author>Plato</author> 
  <price>12.99</price> 
  </book>
  <book>
  <title>The Republic</title> 
  <author>Plato</author> 
  <price>15.99</price> 
  </book>
</books>

and my py file is

>>> from xml.dom.minidom import parse, parseString
>>> s="d:\\i.xml"
>>> doc=parse(s)
>>> doc.childNodeTypes
(1, 7, 8, 10)
>>> doc.nodeName
'#document'
>>> doc.childNodes
[<DOM Element: books at 11502084>]
>>> book=doc.firstChild
>>> book.childNodes
[<DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11610468>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11525428>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11622660>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11630100>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11637540>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11644948>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11652356>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11659756>, <DOM Text node "\n">, <DOM Text node "  ">, <DOM Element: book at 11667156>, <DOM Text node "\n">]
###############   how can I delete the <DOM Text node "\n"> and <DOM Text node "  ">
##      and what is the meaning of (1, 7, 8, 10)(the reslut of doc.childNodeTypes)


__________________________________________

DVD´óƬ£¬Ò»ÂÉ10Ôª  http://shopping.263.net/category02.htm
ÃÀÈÝÑøÑÕ¡¢¼õ·ÊÊÝÉíÃؾ÷  http://shopping.263.net/category10.htm








More information about the Python-list mailing list