1

Given the following xml

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="http://www.test.com/2008/FMSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <tcA codeValue="ANA_01" </tcA>
  <tcB codeValue="ANA_01" </tcB>
  <rbSSFSET2 xsi:nil="true"/>
  <rb2DFiestaFS xsi:nil="true"/>
</module>

I need to retrieve the list of all the children (tag names) without the namespace. Elements that contain the attribute @nil must be avoided.

Using the following piece of code I can retrieve the full list of the child nodes

import xml.etree.ElementTree as ET
mytree = ET.parse('data.xml')
myroot = mytree.getroot()
for element in myroot.iter():
print(element.tag)

but all the names have the namespace as prefix. My second issue is how to avoid to retrieve the children that have the attribute [@nil], since they have their own namespace as well.

Ting
  • 111
  • 5

0 Answers0