[XML-SIG] Parsing help.

Malcolm Tredinnick malcolm at commsecure.com.au
Fri Sep 3 09:28:36 CEST 2004


On Thu, 2004-09-02 at 14:34 +0200, Christian Johansson wrote:
> Hello.
> 
>  
> 
> This might be an trivial question, bet feel free to help a newbee J
> 
>  
> 
> XML:
> 
>  
> 
> - <<appointment id="11667" olid="" start="28.08.2004 09:30:00"
> end="28.08.2004 10:00:00">
> 
>           <subject>TODO</subject> 
> 
>           <body>xxx</body> 
> 
>  </appointment>
> 
>  
> 
> My stupid code:
> 
>  
> 
> doc = xml.dom.minidom.parse(inXML)
> 
> tagSubject = doc.getElementsByTagName('subject')
> 
> for subject in tagSubject:
> 
>   content = subject.nodeValue
> 
>   print content
> 
>  
> 
> Ok so why can I not see the the text “TODO”??
> 
> I have tried many similar approaches, but it just want work…
> 
> If someone can help me, I would become a happy man!

A common mistake when just starting out: the "TODO" string is the
content of a child of the subject node -- the child is a text node. In
this case, it is the first and only child, so you really want to be
looking at subject.firstChild.nodeValue, instead of subject.nodeValue.

Cheers,
Malcolm



More information about the XML-SIG mailing list