class_docstr: Read a GraphML document.  Produces NetworkX graph objects.
class_docstr_tok: ["Read","a","GraphML","document",".","Produces","NetworkX","graph","objects","."]
docstr: Use the key information to decode the data XML if present.
docstr_tok: ["Use","the","key","information","to","decode","the","data","XML","if","present","."]
code: def decode_data_elements(self, graphml_keys, obj_xml):
      """Use the key information to decode the data XML if present."""
      data = {}
      for data_element in obj_xml.findall(f"{{{self.NS_GRAPHML}}}data"):
          key = data_element.get("key")
          try:
              data_name = graphml_keys[key]["name"]
              data_type = graphml_keys[key]["type"]
          except KeyError as err:
              raise nx.NetworkXError(
                  f"Bad GraphML data: no key {key}"
              ) from err
          text = data_element.text
          # assume anything with subelements is a yfiles extension
          if text is not None and len(list(data_element)) == 0:
              if data_type == bool:
                  # Ignore cases.
                  # http://docs.oracle.com/javase/6/docs/api/java/lang/
                  # Boolean.html#parseBoolean%28java.lang.String%29
                  data[data_name] = self.convert_bool[text.lower()]
              else:
                  data[data_name] = data_type(text)
          elif len(list(data_element)) > 0:
              # Assume yfiles as subelements, try to extract node_label
              node_label = None
              # set GenericNode's configuration as shape type
              gn = data_element.find(f"{{{self.NS_Y}}}GenericNode")
              if gn:
                  data["shape_type"] = gn.get("configuration")
              for node_type in [
                  "GenericNode",
                  "ShapeNode",
                  "SVGNode",
                  "ImageNode",
              ]:
                  pref = f"{{{self.NS_Y}}}{node_type}/{{{self.NS_Y}}}"
                  geometry = data_element.find(f"{pref}Geometry")
                  if geometry is not None:
                      data["x"] = geometry.get("x")
                      data["y"] = geometry.get("y")
                  if node_label is None:
                      node_label = data_element.find(f"{pref}NodeLabel")
                  shape = data_element.find(f"{pref}Shape")
                  if shape is not None:
                      data["shape_type"] = shape.get("type")
              if node_label is not None:
                  data["label"] = node_label.text
  
              # check all the different types of edges available in yEd.
              for edge_type in [
                  "PolyLineEdge",
                  "SplineEdge",
                  "QuadCurveEdge",
                  "BezierEdge",
                  "ArcEdge",
              ]:
                  pref = f"{{{self.NS_Y}}}{edge_type}/{{{self.NS_Y}}}"
                  edge_label = data_element.find(f"{pref}EdgeLabel")
                  if edge_label is not None:
                      break
  
              if edge_label is not None:
                  data["label"] = edge_label.text
      return data
  
imports: import warnings
  from collections import defaultdict
  import networkx
  from networkx.utils import open_file
label_desc: Use image node_id 6 for calling the GraphMLReader obj's underlying member method code with example usage: obj.decode_data_elements(graphml_keys, obj_xml) and returns: data