Getting sub elements using minidom

sindangwangi

New Member
I'm trying to get the information contained in the XML below within the api:fields and seem to be running into a road block (there are multiple entry blocks that I am parsing through which contain the api:fields element). I'm having a hard time obtaining the creator, atom_id, href, and id fields.XML\[code\]<entry> <id>533</id> <href>removed</href> <api:fields> <api:field name="creator" type="xs:string" value="http://stackoverflow.com/questions/11312484/me" /> <api:field name="atom_id" type="xs:numeric" value="http://stackoverflow.com/questions/11312484/533" /> <api:field name="href" type="xs:string" value="http://stackoverflow.com/workspaces/533/" /> <api:field name="id" type="xs:numeric" value="http://stackoverflow.com/questions/11312484/533" /> </api:fields></entry>\[/code\]Python\[code\]for result in document_result_xml.getElementsByTagName('api:fields'):for test in result.getElementsByTagName('api:field'): print test print test.nodeValue print type(test)\[/code\]Returns\[code\]<DOM Element: api:field at 0x102ca4ab8>None<type 'instance'>-------<DOM Element: api:field at 0x102ca4f38>None<type 'instance'>-------<DOM Element: api:field at 0x102ca53b0>None<type 'instance'>\[/code\]The print's are my testing pieces. I've tried multiple ways to get the value's within the api:fields (like test.getElementsByTagName("atom_id")[0])
 
Back
Top