Re: [xml] newbie: Python: attribute value from XPath

On Tue, Jan 25, 2005 at 10:12:19PM -0500, Jason Jesso wrote:
How do you get an attribute value from an xmlNode that you get from a 
resulting XPath result set?

e.g. xpath =  //form/input

     <input name="some name" />

This gives me several "input" nodes as a result set, but I want to get the 
value of the name attribute.

I can't seem to find anything in the Python to give me this value.

  node.prop("name") line 3235
    def prop(self, name):
        """Search and get the value of an attribute associated to a
           node This does the entity substitution. This function
           looks in DTD attribute declaration for #FIXED or default
           declaration values unless DTD use has been turned off.
           NOTE: this function acts independently of namespaces
           associated to the attribute. Use xmlGetNsProp() or
           xmlGetNoNsProp() for namespace aware processing. """
        ret = libxml2mod.xmlGetProp(self._o, name)
        return ret


Daniel Veillard      | Red Hat Desktop team
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]