xml.dom.minidom getElementsByTagName white space issue

R. David Murray rdmurray at bitdance.com
Thu Apr 9 17:51:47 CEST 2009


Leonardo lozanne <leolozanne at yahoo.com> wrote:
> Hi,
>  
> I'm getting some XML tags with white spaces from a web service and when I try to get them with the getElements ByTagName I'm not able to do so. I'm getting an empty list. What I'm doing is:
>  
> #XML_response is an xml string
> xml_msg = xml.dom.minidom.parseString(XML_response)
>  
> nodes = xml_msg.getElementsByTagName("tag ten")  #tag name is "tag ten" with a whitespace
>  
> It all works fine with tags like tag_seven but NOT for tag names with a white space. I've tried some escape chars but it doesnt seems to work. 
>  
> Does anybody has the escape char sequence I should be using or a work around for this? Thanks in advanced for your replies. 

As far as I can tell what you are getting is invalid XML.
So I think the answer is "you can't do that".

(cf: http://www.w3.org/TR/2004/REC-xml11-20040204/#NT-NameChar)

--
R. David Murray         http://www.bitdance.com




More information about the Python-list mailing list