[BangPypers] [Small Hitch]Minidom and xml parsing.

Venkatraman S venkat83 at gmail.com
Tue Jul 12 08:58:13 CEST 2011


On Tue, Jul 12, 2011 at 12:20 PM, Subhodip Biswas
<subhodipbiswas at gmail.com>wrote:

>
> I am fairly new to python and i am stuck with a problem.
> What I am  trying to do is parse a xml file using minidom. My xml file
> as almost a structure like this :
>
> <someparentabove>
>       <parent>
>              <child1>
>              </child1>
>              <child2>
>              </child2>
>      </parent>
>      <anotherparent>
>      </anotherparent>
> </someparentabove>
>
> I can get parent along with childs using getElementsByTagName, But is
> there a way I can get only the children (child1 and Child2)?
>

x.getElementsByTagName("parent")[0].childNodes

Btw, you may want to try BeautifulSoup or if you want speed, try :
celementTree.

-V


More information about the BangPypers mailing list