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

<form>
     <input name="some name" />
        ....
        ....
</form>

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 libxml2.py to give me this value.

  node.prop("name")

libxml2.py: 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

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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