[XML-SIG] getAttribute??
Dom Linu
linudom@hotmail.com
Mon, 28 May 2001 21:11:07 -0000
<html><DIV>
<P>Wow -- very informative. Thank you. I was working on the assumption that if namespaces weren't in use, that you use non-namespace functions. That seems to have worked for everything else that I'm doing, but to be honest I can't remember if I've always been using the Sax2 reader-- I would have to dig. I mean, with the Sax2 reader (implied by using FromXml) getElementsByTagName works, without using getElementsByTagNameNS I'm pretty sure... is this inconsistent, or am I missing something? (the latter probably being true!)</P>
<P>dl.<BR><BR></P></DIV>
<DIV></DIV>
<DIV></DIV>>From: Mike Olson <MIKE.OLSON@FOURTHOUGHT.COM>
<DIV></DIV>>To: Dom Linu <LINUDOM@HOTMAIL.COM>
<DIV></DIV>>CC: xml-sig@python.org
<DIV></DIV>>Subject: Re: [XML-SIG] getAttribute??
<DIV></DIV>>Date: Mon, 28 May 2001 14:48:52 -0600
<DIV></DIV>>
<DIV></DIV>>Dom Linu wrote:
<DIV></DIV>> >
<DIV></DIV>> > I have tried this many different ways, but it never seems to work and
<DIV></DIV>> > I always abandon PyXML in favor of something else... so I'll ask here,
<DIV></DIV>> > why does this fail:
<DIV></DIV>> >
<DIV></DIV>> > >>> from xml.dom.ext.reader.Sax2 import FromXml
<DIV></DIV>> > >>> doc = FromXml("<MYDOC id=123>text here</MYDOC>")
<DIV></DIV>> > >>> elem = doc.documentElement
<DIV></DIV>> > >>> attr = elem.getAttribute("id")
<DIV></DIV>> > >>> print attr
<DIV></DIV>> >
<DIV></DIV>> > >>> type(attr)
<DIV></DIV>> > <TYPE ?string?>
<DIV></DIV>>
<DIV></DIV>>Because the Sax2 reader is namespace aware so you need to use the DOM
<DIV></DIV>>level II interface of getAttributeNS('','id')
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>> >
<DIV></DIV>> > I've tried other document, other platforms (both Unix and Win32), and
<DIV></DIV>> > other techniques, but I just can't seem to get an attribute. Any
<DIV></DIV>> > enlightenment would be illuminating.
<DIV></DIV>> >
<DIV></DIV>> > thx.
<DIV></DIV>> >
<DIV></DIV>> >
<DIV></DIV>> > ----------------------------------------------------------------------
<DIV></DIV>> > Get your FREE download of MSN Explorer at http://explorer.msn.com
<DIV></DIV>> >
<DIV></DIV>> > _______________________________________________ XML-SIG maillist -
<DIV></DIV>> > XML-SIG@python.org http://mail.python.org/mailman/listinfo/xml-sig
<DIV></DIV>>
<DIV></DIV>>--
<DIV></DIV>>Mike Olson Principal Consultant
<DIV></DIV>>mike.olson@fourthought.com (303)583-9900 x 102
<DIV></DIV>>Fourthought, Inc. http://Fourthought.com
<DIV></DIV>>Software-engineering, knowledge-management, XML, CORBA, Linux, Python
<DIV></DIV>>
<DIV></DIV>>_______________________________________________
<DIV></DIV>>XML-SIG maillist - XML-SIG@python.org
<DIV></DIV>>http://mail.python.org/mailman/listinfo/xml-sig
<DIV></DIV><br clear=all><hr>Get your FREE download of MSN Explorer at <a href="http://explorer.msn.com">http://explorer.msn.com</a><br></p></html>