Hello,

Let say I have this XML chunk:


<?xml version="1.0"?>

<root>
  <sceneobject name="Camera_Root" fullname="Camera_Root" type="CameraRoot">
    <properties>
      <property name="Visibility" fullname="Camera_Root.visibility"
type="visibility">
        <parameters>
          <parameter scriptname="viewvis"
fullname="Camera_Root.visibility.viewvis" type="Parameter"
sourceclassname="nosource">False</parameter>


I wish to retrieve the "False" between the opening/closing tags.
I thought I could use something like:


from elementtree.ElementTree import parse

oTree = parse( r'C:\temp\Camera_Root.xml' )

for oXMLObject in oTree.findall( '//sceneobject' ):
        if oXMLObject.attrib[ 'type' ] == 'CameraRoot':
                
                oXMLProps = oXMLObject.find( 'properties' )
                
                # We found the tag
                for oXMLProp in oXMLProps.findall( 'property' ):
                        if oXMLProp.attrib[ 'name' ] == 'Visibility':
                                print oXMLProp.text


Now the print statements prints an empty line, wich is obviously not
what I'm after :-)


Thanks
Bernard
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to