Construct a dom Element from a string. A utility function for creating
DOM elements when needed for other builder functions.

@param xmlString
XML for an element.
@return w3c.dom.Element representation the provided XML.
192191
public static org.w3c.dom.Element domElement(String xmlString) {
    org.w3c.dom.Element element = null;
    try {
      ByteArrayInputStream bais = new ByteArrayInputStream(
        xmlString.getBytes(Charset.forName("UTF-8")));
      element = getFactory().newDocumentBuilder().parse(bais)
        .getDocumentElement();
    } catch (SAXException e) {
      throw new MarkLogicIOException(
        "Could not make Element from xmlString" + xmlString, e);
    } catch (IOException e) {
      throw new MarkLogicIOException(
        "Could not make Element from xmlString" + xmlString, e);
    } catch (ParserConfigurationException e) {
      throw new MarkLogicIOException(
        "Could not make Element from xmlString" + xmlString, e);
    }
    return element;
  }
728968
public static Document stringToDocument(String xml) {
        try {
            SAXBuilder sax = new SAXBuilder();
            return sax.build(new ByteArrayInputStream(xml.getBytes("UTF-8")));
        } catch (JDOMException e) {
            throw new IllegalArgumentException("Unable to parse xml", e);
        } catch (IOException e) {
            throw new IllegalArgumentException("Unable to parse xml", e);
        }
    }
655405
def _create_xml_node(tag, prefix=None, ns=None):
    """"""
    if prefix and ns:
        ET.register_namespace(prefix, ns)
    if ns:
        return ET.Element("{"+ns+"}"+tag)
    else:
        return ET.Element(tag)
1019157
@Override
    public XmlStringBuilder toXML() {
        XmlStringBuilder buf = new XmlStringBuilder();
        buf.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket();

        for (BookmarkedURL urlStorage : getBookmarkedURLS()) {
            if (urlStorage.isShared()) {
                continue;
            }
            buf.halfOpenElement("url").attribute("name", urlStorage.getName()).attribute("url", urlStorage.getURL());
            buf.condAttribute(urlStorage.isRss(), "rss", "true");
            buf.closeEmptyElement();
        }

        // Add Conference additions
        for (BookmarkedConference conference : getBookmarkedConferences()) {
            if (conference.isShared()) {
                continue;
            }
            buf.halfOpenElement("conference");
            buf.attribute("name", conference.getName());
            buf.attribute("autojoin", Boolean.toString(conference.isAutoJoin()));
            buf.attribute("jid", conference.getJid());
            buf.rightAngleBracket();

            buf.optElement("nick", conference.getNickname());
            buf.optElement("password", conference.getPassword());

            buf.closeElement("conference");
        }

        buf.closeElement(ELEMENT);
        return buf;
    }
915590
public static Document constructDocumentFromXml(final String xmlString) {
        try {
            val builder = new SAXBuilder();
            builder.setFeature("http://xml.org/sax/features/external-general-entities", false);
            builder.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
            return builder.build(new ByteArrayInputStream(xmlString.getBytes(Charset.defaultCharset())));
        } catch (final Exception e) {
            LOGGER.error(e.getMessage(), e);
            return null;
        }
    }
1301527
public function parseString($xmlString, $xmlFile = null)
    {
        // we don't want infinite recursion
        if ($this->isAlreadyParsed($xmlFile)) {
            return;
        }
        // store current schema file path
        $this->schemasTagsStack[$xmlFile] = [];
        $this->currentXmlFile = $xmlFile;

        $parser = xml_parser_create();
        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
        xml_set_object($parser, $this);
        xml_set_element_handler($parser, 'startElement', 'endElement');
        if (!xml_parse($parser, $xmlString)) {
            throw new SchemaException(sprintf('XML error: %s at line %d',
                xml_error_string(xml_get_error_code($parser)),
                xml_get_current_line_number($parser))
            );
        }
        xml_parser_free($parser);

        array_pop($this->schemasTagsStack);

        return $this->schema;
    }
746044
public static function innerXML(\DOMNode $node, $xmlstring)
    {
        $xmlstring = str_replace("<br>", "<br/>", $xmlstring);
        $len = strlen($xmlstring);
        $endText = "";
        $close = strrpos($xmlstring, '>');
        if ($close !== false && $close < $len - 1) {
            $endText = substr($xmlstring, $close + 1);
            $xmlstring = substr($xmlstring, 0, $close + 1);
        }
        $open = strpos($xmlstring, '<');
        if ($open === false) {
            $node->nodeValue .= $xmlstring;
        } else {
            if ($open > 0) {
                $text = substr($xmlstring, 0, $open);
                $xmlstring = substr($xmlstring, $open);
                $node->nodeValue .= $text;
            }
            $dom = XmlUtil::getOwnerDocument($node);
            $xmlstring = "<rootxml>$xmlstring</rootxml>";
            $sxe = @simplexml_load_string($xmlstring);
            if ($sxe === false) {
                throw new XmlUtilException("Cannot load XML string.", 252);
            }
            $domSimpleXml = dom_import_simplexml($sxe);
            if (!$domSimpleXml) {
                throw new XmlUtilException("XML Parsing error.", 253);
            }
            $domSimpleXml = $dom->importNode($domSimpleXml, true);
            $childs = $domSimpleXml->childNodes->length;
            for ($i = 0; $i < $childs; $i++) {
                $node->appendChild($domSimpleXml->childNodes->item($i)->cloneNode(true));
            }
        }
        if (!empty($endText) && $endText != "") {
            $textNode = $dom->createTextNode($endText);
            $node->appendChild($textNode);
        }
        return $node->firstChild;
    }
1275226
def __createElementNS(self, root, uri, name, value):
        '''
        
        '''
        tag = root.ownerDocument.createElementNS(to_unicode(uri),
                                                 to_unicode(name))
        tag.appendChild(root.ownerDocument
                        .createCDATASection(to_unicode(value)))
        return root.appendChild(tag)
903507
function decodeXML( $xmlString )
    {
        $dom = new DOMDocument( '1.0', 'utf-8' );
        $success = $dom->loadXML( $xmlString );
        if ( $xmlString != "" )
        {
            // set the name of the node
            $nameArray = $dom->getElementsByTagName( "name" );
            $this->setName( $nameArray->item( 0 )->textContent );

            $columnsNode = $dom->getElementsByTagName( "columns" )->item( 0 );
            $numColumns = $columnsNode->getAttribute( 'number');

            $rowsNode = $dom->getElementsByTagName( "rows" )->item( 0 );
            $numRows = $rowsNode->getAttribute( 'number' );

            $namedColumns = $dom->getElementsByTagName( "column" );
            $namedColumnList = array();
            if ( $namedColumns->length > 0 )
            {
                foreach ( $namedColumns as $namedColumn )
                {
                    $columnName = $namedColumn->textContent;
                    $columnID = $namedColumn->getAttribute( 'id' );
                    $columnNumber = $namedColumn->getAttribute( 'num' );
                    $namedColumnList[$columnNumber] = array( 'name' => $columnName,
                                                             'column_number' => $columnNumber,
                                                             'column_id' => $columnID );
                }
            }
            $cellNodes = $dom->getElementsByTagName( "c" );
            $cellList = array();
            foreach ( $cellNodes as $cellNode )
            {
                $cellList[] = $cellNode->textContent;
            }

            $rows = array( 'sequential' => array() );
            $sequentialRows = array();

            for ( $i = 1; $i <= $numRows; $i++ )
            {
                $row = array( 'identifier' => 'row_' . $i ,
                              'name' => 'Row_' . $i );
                $rowColumns = array();
                for ( $j = 1; $j <= $numColumns; $j++ )
                {
                    $rowColumns[] = $cellList[ ($i-1) * $numColumns + $j-1];
                }
                $row['columns'] = $rowColumns;
                $sequentialRows[] = $row;
            }
            $rows['sequential'] = $sequentialRows;

            $columns = array( 'sequential' => array(),
                              'id' => array() );
            $sequentialColumns = array();
            $idColumns = array();

            for ( $i = 0; $i < $numColumns; $i++ )
            {
                if ( isset( $column ) )
                    unset( $column );
                $column = array();
                if ( isset( $namedColumnList[$i] ) && is_array( $namedColumnList[$i] ) )
                {
                    $column = array( 'identifier' => $namedColumnList[$i]['column_id'],
                                     'index' => $i,
                                     'name' => $namedColumnList[$i]['name'] );
                }
                else
                {
                    $column = array( 'identifier' => 'col_' . ($i + 1),
                                     'index' => $i,
                                     'name' => 'Col_' . ($i + 1) );

                }

                $columnRows = array();
                for( $j = 0; $j < $numRows; $j++ )
                {
                    $columnRows[] = $sequentialRows[$j]['columns'][$i];
                }
                $column['rows'] = $columnRows;
                $sequentialColumns[] = $column;
                $idColumns[$column['identifier']] = $column;
            }
            $columns['sequential'] = $sequentialColumns;
            $columns['id'] = $idColumns;

            $matrix = array( 'rows' => $rows,
                             'columns' => $columns,
                             'cells' => $cellList );

            $this->Matrix = $matrix;
            $this->NumRows = $numRows;
            $this->NumColumns = $numColumns;
            $this->Cells = $cellList;
        }
        else
        {
            $this->Cells = array();
            $this->Matrix = array();
        }
    }
1069501
public function fromString($xmlString)
    {
        $xml = $this->createDomDocument();
        $xml->loadXml($xmlString);

        return new Document($xml);
    }
587632
function(string) {
  if (!string) {
    var fragment = document.createDocumentFragment();
    fragment.appendChild(document.createTextNode(''));
    return fragment;
  }
  var templateElement;
  templateElement = document.createElement('template');
  templateElement.innerHTML = string;
  return templateElement.content;
}
1248915
public XMLString xstr()
  {
    int node = item(0);
    return (node != DTM.NULL) ? getStringFromNode(node) : XString.EMPTYSTRING;
  }
1128965
public XMLDocument addXML(String xmlString, boolean excludeRoot) throws SAXException{
        if(!StringUtil.isWhitespace(xmlString))
            addXML(new InputSource(new StringReader(xmlString)), excludeRoot);
        return this;
    }
508020
function XmlElement(tag) {
  // Capture the parser object off of the XmlDocument delegate
  var parser = delegates[delegates.length - 1].parser;

  this.name = tag.name;
  this.attr = tag.attributes || {};
  this.val = "";
  this.children = [];
  this.firstChild = null;
  this.lastChild = null;

  // Assign parse information
  this.line = parser.line;
  this.column = parser.column;
  this.position = parser.position;
  this.startTagPosition = parser.startTagPosition;
}
1370816
XML makeXmlFromString(XMLName name, String value) {
        try {
            return newTextElementXML(this.node, name.toQname(), value);
        } catch(Exception e) {
            throw ScriptRuntime.typeError(e.getMessage());
        }
    }
306075
public static String serialize(String xmlString) {
        StringWriter sw = new StringWriter();
        serialize(asStreamSource(xmlString), sw);
        return sw.toString();
    }
629181
public function parseXml($xmlString)
    {
        Validate::notNull($xmlString, 'xmlString');
        Validate::isString($xmlString, 'xmlString');

        $this->fromXml(simplexml_load_string($xmlString));
    }