[XML-SIG] getAttribute??

Dom Linu linudom@hotmail.com
Mon, 28 May 2001 21:11:07 -0000

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