[XML-SIG] getAttribute??

Mike Olson Mike.Olson@fourthought.com
Mon, 28 May 2001 14:48:52 -0600


Dom Linu wrote:
> 
> I have tried this many different ways, but it never seems to work and
> I always abandon PyXML in favor of something else... so I'll ask here,
> why does this fail:
> 
> >>> from xml.dom.ext.reader.Sax2 import FromXml
> >>> doc = FromXml("<mydoc id='123'>text here</mydoc>")
> >>> elem = doc.documentElement
> >>> attr = elem.getAttribute("id")
> >>> print attr
> 
> >>> type(attr)
> <type 'string'>

Because the Sax2 reader is namespace aware so you need to use the DOM
level II interface of getAttributeNS('','id')


> 
> I've tried other document, other platforms (both Unix and Win32), and
> other techniques, but I just can't seem to get an attribute.  Any
> enlightenment would be illuminating.
> 
> thx.
> 
> 
> ----------------------------------------------------------------------
> Get your FREE download of MSN Explorer at http://explorer.msn.com
> 
> _______________________________________________ XML-SIG maillist -
> XML-SIG@python.org http://mail.python.org/mailman/listinfo/xml-sig

-- 
Mike Olson				 Principal Consultant
mike.olson@fourthought.com               (303)583-9900 x 102
Fourthought, Inc.                         http://Fourthought.com 
Software-engineering, knowledge-management, XML, CORBA, Linux, Python