(xml_element, mjcf_element, escape_separators=False)
Parses all children of a given XML element into an MJCF element.

  Args:
    xml_element: The source `etree.Element` object.
    mjcf_element: The target `mjcf.Element` object.
    escape_separators: (optional) A boolean, whether to replace '/' characters
      in element identifiers. If `False`, any '/' present in the XML causes
      a ValueError to be raised.
Parses all children of a given XML element into an MJCF element.
Parses all children of a given XML element into an MJCF element .
def _parse_children(xml_element, mjcf_element, escape_separators=False):
  """Parses all children of a given XML element into an MJCF element.

  Args:
    xml_element: The source `etree.Element` object.
    mjcf_element: The target `mjcf.Element` object.
    escape_separators: (optional) A boolean, whether to replace '/' characters
      in element identifiers. If `False`, any '/' present in the XML causes
      a ValueError to be raised.
  """
  for xml_child in xml_element:
    if xml_child.tag is etree.Comment or xml_child.tag is etree.PI:
      continue
    try:
      child_spec = mjcf_element.spec.children[xml_child.tag]
      if escape_separators:
        attributes = {}
        for name, value in xml_child.attrib.items():
          new_value = value.replace(
              constants.PREFIX_SEPARATOR_ESCAPE,
              constants.PREFIX_SEPARATOR_ESCAPE * 2)
          new_value = new_value.replace(
              constants.PREFIX_SEPARATOR, constants.PREFIX_SEPARATOR_ESCAPE)
          attributes[name] = new_value
      else:
        attributes = dict(xml_child.attrib)
      if child_spec.repeated or child_spec.on_demand:
        mjcf_child = mjcf_element.add(xml_child.tag, **attributes)
      else:
        mjcf_child = getattr(mjcf_element, xml_child.tag)
        mjcf_child.set_attributes(**attributes)
    except:  # pylint: disable=bare-except
      err_type, err, traceback = sys.exc_info()
      raise err_type(
          f'Line {xml_child.sourceline}: error while parsing element '
          f'<{xml_child.tag}>: {err}').with_traceback(traceback)
    _parse_children(xml_child, mjcf_child, escape_separators)
def _parse_children ( xml_element , mjcf_element , escape_separators = False ) : for xml_child in xml_element : if xml_child . tag is etree . Comment or xml_child . tag is etree . PI : continue try : child_spec = mjcf_element . spec . children [ xml_child . tag ] if escape_separators : attributes = { } for name , value in xml_child . attrib . items ( ) : new_value = value . replace ( constants . PREFIX_SEPARATOR_ESCAPE , constants . PREFIX_SEPARATOR_ESCAPE * 2 ) new_value = new_value . replace ( constants . PREFIX_SEPARATOR , constants . PREFIX_SEPARATOR_ESCAPE ) attributes [ name ] = new_value else : attributes = dict ( xml_child . attrib ) if child_spec . repeated or child_spec . on_demand : mjcf_child = mjcf_element . add ( xml_child . tag , * * attributes ) else : mjcf_child = getattr ( mjcf_element , xml_child . tag ) mjcf_child . set_attributes ( * * attributes ) except : # pylint: disable=bare-except err_type , err , traceback = sys . exc_info ( ) raise err_type ( f'Line {xml_child.sourceline}: error while parsing element ' f'<{xml_child.tag}>: {err}' ) . with_traceback ( traceback ) _parse_children ( xml_child , mjcf_child , escape_separators )