sunpy.util.xml.node_to_dict(node)[source] [edit on github]

node_to_dict() scans through the children of node and makes a dictionary from the content.

Three cases are differentiated:

  1. If the node contains no other nodes, it is a text-node and {nodeName: text} is merged into the dictionary.
  2. If the node has the attribute “method” set to “true”, then it’s children will be appended to a list and this list is merged to the dictionary in the form: {nodeName:list}.
  3. Else, node_to_dict() will call itself recursively on the nodes children (merging {nodeName: node_to_dict()} to the dictionary).