Emit the options as xml.

@param root
@param str
@throws OptionsException
483987
public void toXml(final OptionElement root, final OutputStream str) throws OptionsException {
    Writer wtr = null;

    try {
      XmlEmit xml = new XmlEmit(true);

      wtr = new OutputStreamWriter(str);
      xml.startEmit(wtr);

      xml.openTag(outerTag);

      for (OptionElement oe: root.getChildren()) {
        childToXml(oe, xml);
      }

      xml.closeTag(outerTag);
    } catch (OptionsException ce) {
      throw ce;
    } catch (Throwable t) {
      throw new OptionsException(t);
    } finally {
      if (wtr != null) {
        try {
          wtr.close();
        } catch (Throwable t) {}
      }
    }
  }
627154
public static String mapToXmlStr(Map<?, ?> data, String rootName) {
		return toStr(mapToXml(data, rootName));
	}
273295
function parse(str, options) {
  var doc = options.document || 'xml'
    , pretty = options.pretty || false
    , js = str;
  
  return ''
    + 'var ' + doc + ' = factory();\n'
    + (options.self
      ? 'var self = locals || {};\n' + js
      : 'with (locals || {}) {\n' + js + '\n}\n')
    + 'return ' + doc + '.toString({ pretty: ' + pretty + ' })';
}
177622
function root(node, options = {}) {
  const {
    fragment,
    namespace: optionsNamespace,
  } = options;
  const { children = [] } = node;
  const { length: childrenLength } = children;

  let namespace = optionsNamespace;
  let rootIsDocument = childrenLength === 0;

  for (let i = 0; i < childrenLength; i += 1) {
    const {
      tagName,
      properties: {
        xmlns,
      } = {},
    } = children[i];
    if (tagName === 'html') {
      // If we have a root HTML node, we don't need to render as a fragment
      rootIsDocument = true;
      // Take namespace of first child
      if (typeof optionsNamespace === 'undefined') {
        if (xmlns) {
          namespace = xmlns;
        } else if (children[0].tagName === 'html') {
          namespace = 'http://www.w3.org/1999/xhtml';
        }
      }
    }
  }

  // The root node will be a Document, DocumentFragment, or HTMLElement
  let el;
  if (rootIsDocument) {
    el = document.implementation.createDocument(namespace, '', null);
  } else if (fragment) {
    el = document.createDocumentFragment();
  } else {
    el = document.createElement('html');
  }

  // Transform children
  const childOptions = Object.assign({ fragment, namespace }, options);
  for (let i = 0; i < childrenLength; i += 1) {
    const childEl = transform(children[i], childOptions);
    if (childEl) {
      el.appendChild(childEl);
    }
  }

  return el;
}
165287
def write_xml(self, root):
        """"""

        if not self.extended:
            try:
                source_element = utils.create_xml_element(root, 'source',
                                                          dict(name=self['Source_Name'],
                                                               type='PointSource'))
            except TypeError as msg:
                print (self['Source_Name'], self)
                raise TypeError(msg)

            spat_el = ElementTree.SubElement(source_element, 'spatialModel')
            spat_el.set('type', 'SkyDirFunction')

        elif self['SpatialType'] == 'SpatialMap':
            source_element = utils.create_xml_element(root, 'source',
                                                      dict(name=self['Source_Name'],
                                                           type='DiffuseSource'))

            filename = utils.path_to_xmlpath(self['Spatial_Filename'])
            spat_el = utils.create_xml_element(source_element, 'spatialModel',
                                               dict(map_based_integral='True',
                                                    type='SpatialMap',
                                                    file=filename))
        else:
            source_element = utils.create_xml_element(root, 'source',
                                                      dict(name=self['Source_Name'],
                                                           type='DiffuseSource'))
            spat_el = utils.create_xml_element(source_element, 'spatialModel',
                                               dict(type=self['SpatialType']))

        for k, v in self.spatial_pars.items():
            utils.create_xml_element(spat_el, 'parameter', v)

        el = ElementTree.SubElement(source_element, 'spectrum')

        stype = self['SpectrumType'].strip()
        el.set('type', stype)

        if self['Spectrum_Filename'] is not None:
            filename = utils.path_to_xmlpath(self['Spectrum_Filename'])
            el.set('file', filename)

        for k, v in self.spectral_pars.items():
            utils.create_xml_element(el, 'parameter', v)
604283
def get_xml_root_from_str(xml_str):
    """"""
    try:
        xml_root = etree.fromstring(xml_str.encode("utf-8"), NO_BLANKS_PARSER)
    # pylint: disable=broad-except
    except Exception as err:
        raise Dump2PolarionException("Failed to parse XML string: {}".format(err))
    return xml_root
764742
public void xmlDeclaration(Map<String, Object> args) {
        Map<String, Map<String, Object>> map = new HashMap<String, Map<String, Object>>();
        map.put("xml", args);
        pi(map);
    }
983852
@Override
    public String execute(EditXmlInputs inputs) throws Exception {
        Document doc = XmlUtils.createDocument(inputs.getXml(), inputs.getFilePath(), inputs.getParsingFeatures());
        NodeList nodeList = XmlUtils.readNode(doc, inputs.getXpath1(), XmlUtils.getNamespaceContext(inputs.getXml(), inputs.getFilePath()));
        Node node;
        Node childNode = XmlUtils.stringToNode(inputs.getValue(), doc.getXmlEncoding(), inputs.getParsingFeatures());

        for (int i = 0; i < nodeList.getLength(); i++) {
            childNode = doc.importNode(childNode, true);
            node = nodeList.item(i);
            node.appendChild(childNode);
        }
        return DocumentUtils.documentToString(doc);
    }
1303844
@Override
  public void setOptions(String[] options) throws Exception {
    setDebug(Utils.getFlag("D", options));
    Utils.checkForRemainingOptions(options);
  }
684866
public String execute(final String pointerStr, final Source source)
    {
        try
        {
            final StringWriter stringWriter = new StringWriter();
            final Serializer serializer = processor.newSerializer(stringWriter);
            serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "yes");
            executeToDestination(pointerStr, source, serializer);
            return stringWriter.toString();
        }
        catch (final XPointerException e)
        {
            final String message = e.getLocalizedMessage();
            if (xPointerErrorHandler != null)
            {
                xPointerErrorHandler.reportError(message);
            }
            else
            {
                LOG.error(message, e);
            }
        }
        return "";
    }
1287540
@Override
    public AMPExtension parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment)
                    throws XmlPullParserException, IOException {
        final String from = parser.getAttributeValue(null, "from");
        final String to = parser.getAttributeValue(null, "to");
        final String statusString = parser.getAttributeValue(null, "status");
        AMPExtension.Status status = null;
        if (statusString != null) {
            try {
                status = AMPExtension.Status.valueOf(statusString);
            } catch (IllegalArgumentException ex) {
                LOGGER.severe("Found invalid amp status " + statusString);
            }
        }

        AMPExtension ampExtension = new AMPExtension(from, to, status);

        String perHopValue = parser.getAttributeValue(null, "per-hop");
        if (perHopValue != null) {
            boolean perHop = Boolean.parseBoolean(perHopValue);
            ampExtension.setPerHop(perHop);
        }

        boolean done = false;
        while (!done) {
            int eventType = parser.next();
            if (eventType == XmlPullParser.START_TAG) {
                if (parser.getName().equals(AMPExtension.Rule.ELEMENT)) {
                    String actionString = parser.getAttributeValue(null, AMPExtension.Action.ATTRIBUTE_NAME);
                    String conditionName = parser.getAttributeValue(null, AMPExtension.Condition.ATTRIBUTE_NAME);
                    String conditionValue = parser.getAttributeValue(null, "value");

                    AMPExtension.Condition condition = createCondition(conditionName, conditionValue);
                    AMPExtension.Action action = null;
                    if (actionString != null) {
                        try {
                            action = AMPExtension.Action.valueOf(actionString);
                        } catch (IllegalArgumentException ex) {
                            LOGGER.severe("Found invalid rule action value " + actionString);
                        }
                    }

                    if (action == null || condition == null) {
                        LOGGER.severe("Rule is skipped because either it's action or it's condition is invalid");
                    } else {
                        AMPExtension.Rule rule = new AMPExtension.Rule(action, condition);
                        ampExtension.addRule(rule);
                    }
                }
            } else if (eventType == XmlPullParser.END_TAG) {
                if (parser.getName().equals(AMPExtension.ELEMENT)) {
                    done = true;
                }
            }
        }

        return ampExtension;
    }
960956
private void saveSummaryXml(SampleNode root) {

        root.sortTree();
        Document doc = DocumentHelper.createDocument();
        Element rootElem = doc.addElement("root");
        root.appendToXml(rootElem);
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        outformat.setEncoding("UTF-8");
        try {
            XMLWriter writer = new XMLWriter(buffer, outformat);
            writer.write(doc);
            writer.flush();
            try (FileOutputStream fos = new FileOutputStream(m_summaryFilename)) {
                fos.write(buffer.toByteArray());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
190925
def xml(self, value):
        """"""

        self._xml = value
        self._root = s2t(value)
606463
private static Document createXML(String root, boolean useNamespace) {
		try {
			org.w3c.dom.Document doc = getDocumentBuilder(null, useNamespace).newDocument();
			doc.appendChild(doc.createElement(root));
			return new DocumentImpl(doc);
		} catch (Exception e) {
			throw new DomException(e);
		}
	}
220498
@SuppressWarnings({ "unchecked", "rawtypes" })
    public static Map<String,Object> xmlToProperties(String strProperties)
    {
        Properties properties = new Properties();
        if ((strProperties != null) && (strProperties.length() > 0))
        {
            strProperties = DTD + strProperties;
            ByteArrayOutputStream baOut = new ByteArrayOutputStream();
            OutputStreamWriter osOut = new OutputStreamWriter(baOut);
            try   {
                osOut.write(strProperties);     // Char->Byte
                osOut.flush();
                baOut.flush();
                ByteArrayInputStream baIn = new ByteArrayInputStream(baOut.toByteArray());
                properties.loadFromXML(baIn);
            } catch (IOException ex)    {
                ex.printStackTrace();
            }
        }
        return (Map)properties;
    }
965285
public static String toXml(Object root, Class clazz, String encoding) {
		try {
			StringWriter writer = new StringWriter();
			createMarshaller(clazz, encoding).marshal(root, writer);
			return writer.toString();
		} catch (JAXBException e) {
			throw ExceptionUtil.unchecked(e);
		}
	}
1236578
public void setRootNode(TreeElement rootNode)
    {
        _rootNode = rootNode;
        if (rootNode.getName() == null) {
            rootNode.setName("0");
        }
    }