J'essaie d'obtenir une liste d'éléments avec un type xsd spécifique avec lxml 2.x et je n'arrive pas à comprendre comment traverser xsd pour des types spécifiques.Rechercher des éléments basés sur le type xsd avec lxml
Exemple de schéma:
<xsd:element name="ServerOwner" type="srvrs:string90" minOccurs="0">
<xsd:element name="HostName" type="srvrs:string35" minOccurs="0">
Exemple de données xml:
<srvrs:ServerOwner>John Doe</srvrs:ServerOwner>
<srvrs:HostName>box01.example.com</srvrs:HostName>
La fonction idéale ressemblerait à ceci:
elements = getElems(xml_doc, 'string90')
def getElems(xml_doc, xsd_type):
** xpath or something to find the elements and build a dict
return elements