Parse prefix or suffix.

@param dc      DOM-document.
@param tagname tag name.
@return template.
555321
private Template parseFix(Document dc, String tagname) {
        Template fix;
        NodeList prefixElementList = dc.getElementsByTagNameNS(SCHEMA_LOCATION, tagname);
        if (prefixElementList.getLength() > 0) {
            fix = parseTemplate(prefixElementList.item(0));
        } else {
            fix = new Template();
        }
        return fix;
    }
394992
function getDomDocumentPrefix() {
	if (getDomDocumentPrefix.prefix)
		return getDomDocumentPrefix.prefix;
	
	var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
	var o;
	for (var i = 0; i < prefixes.length; i++) {
		try {
			// try to create the objects
			o = new ActiveXObject(prefixes[i] + ".DomDocument");
			return getDomDocumentPrefix.prefix = prefixes[i];
		}
		catch (ex) {};
	}
	
	throw new Error("Could not find an installed XML parser");
}
17180
private final void parseDocument(Node currentNode) {
	    	try {
	    		mutex.acquire();
	        String nodeName = currentNode.getNodeName();
	
	        if ((currentNode.getNodeType() == Node.ELEMENT_NODE)
	                && (nodeName.equals("type"))
	        ) {
	            String typeName = ((Element) currentNode).getAttribute("name");
	            mapFilter.put(
	                typeName + ".filter",
	                new ArrayList()
	            );
	            mapFilter.put(
	                typeName + ".tag",
	                new ArrayList()
	            );
	            mapFilter.put(
	                typeName + ".merge",
	                new ArrayList()
	            );
	        }
	
	        if ((currentNode.getNodeType() == Node.ELEMENT_NODE)
	                && (currentNode.getParentNode() != null)
	        ) {
	            if (nodeName.equals("filter")) {
	                String typeName =
	                    ((Element) currentNode.getParentNode()
	                                          .getParentNode()).getAttribute(
	                        "name"
	                    );
	                ArrayList vMapFilter =
	                    (ArrayList) mapFilter.get(typeName + ".filter");
	                ArrayList vFilter = new ArrayList();
	                int iOrder =
	                    ((Element) currentNode).getAttribute("order")
	                     .equals("")
	                    ? vMapFilter.size()
	                    : Integer.parseInt(
	                        ((Element) currentNode).getAttribute("order")
	                    );
	                String replacement = "";
	                NodeList nl = currentNode.getChildNodes();
	
	                for (int i = 0; i < nl.getLength(); i++) {
	                    Node childNode = nl.item(i);
	
	                    if (childNode.getNodeName()
	                                     .equals("replacement")) {
	                        NodeList nl2 = childNode.getChildNodes();
	
	                        for (int j = 0; j < nl2.getLength(); j++) {
	                            Node child = nl2.item(j);
	
	                            if (child.getNodeType() == Node.TEXT_NODE) {
	                                replacement =
	                                    replacement + child.getNodeValue();
	                            }
	                        }
	                    } else if (childNode.getNodeName()
	                                            .equals("match")) {
	                        String match = "";
	                        NodeList nl2 = childNode.getChildNodes();
	
	                        for (int j = 0; j < nl2.getLength(); j++) {
	                            Node child = nl2.item(j);
	
	                            if (child.getNodeType() == Node.TEXT_NODE) {
	                                match = match + child.getNodeValue();
	                            }
	                        }
	
	                        Pattern p = null;
	
	                        try {
	                            p = Pattern.compile(
	                                    match,
	                                    Pattern.MULTILINE | Pattern.DOTALL
	                                );
	                            vFilter.add(p);
	                        } catch (Exception ignore) {
	                        }
	                    }
	                }
	
	                vMapFilter.add(
	                    iOrder,
	                    new Object[] {
	                        replacement,
	                        vFilter
	                    }
	                );
	            } else if ((nodeName.equals("tag"))
	                    && (
	                        currentNode.getParentNode().getNodeName().equals(
	                            "tags"
	                        )
	                    )
	            ) {
	                String typeName =
	                    ((Element) currentNode.getParentNode()
	                                          .getParentNode()
	                                          .getParentNode()).getAttribute(
	                        "name"
	                    );
	                String tagName = ((Element) currentNode).getAttribute("name");
	                ArrayList vMapTags =
	                    (ArrayList) mapFilter.get(typeName + ".tag");
	                ArrayList vAttributes = new ArrayList();
	                NodeList nl = currentNode.getChildNodes();
	
	                for (int i = 0; i < nl.getLength(); i++) {
	                    Node childNode = nl.item(i);
	
	                    if (childNode.getNodeName()
	                                     .equals("attribute")) {
	                        vAttributes.add(
	                            (String) ((Element) childNode).getAttribute("name")
	                        );
	                    }
	                }
	
	                vMapTags.add(new Object[] {
	                        tagName,
	                        vAttributes
	                    }
	                );
	            } else if (nodeName.equals("source_attribute")) {
	                String typeName =
	                    ((Element) currentNode.getParentNode()
	                                          .getParentNode()
	                                          .getParentNode()
	                                          .getParentNode()).getAttribute(
	                        "name"
	                    );
	                String tagName =
	                    ((Element) currentNode.getParentNode()).getAttribute(
	                        "name"
	                    );
	                String attribName =
	                    ((Element) currentNode).getAttribute("name");
	                String srcAttribNameInDest =
	                    ((Element) currentNode).getAttribute("name_in_destination");
	                ArrayList vMapMerge =
	                    (ArrayList) mapFilter.get(typeName + ".merge");
	                String separator = null;
	                String destAttribName = null;
	                ArrayList match = new ArrayList();
	                ArrayList value = new ArrayList();
	                NodeList nl = currentNode.getChildNodes();
	
	                for (int i = 0; i < nl.getLength(); i++) {
	                    Node childNode = nl.item(i);
	
	                    if (childNode.getNodeName()
	                                     .equals("destination_attribute")) {
	                        destAttribName =
	                            ((Element) childNode).getAttribute("name");
	                    } else if (childNode.getNodeName()
	                                            .equals("separator")) {
	                        separator = ((Element) childNode).getAttribute("value");
	                    } else if (childNode.getNodeName()
	                                            .equals("replace")) {
	                        match.add(((Element) childNode).getAttribute("match"));
	                        value.add(((Element) childNode).getAttribute("value"));
	                    }
	                }
	
	                vMapMerge.add(
	                    new Object[] {
	                        tagName,
	                        attribName,
	                        srcAttribNameInDest,
	                        destAttribName,
	                        separator,
	                        match,
	                        value
	                    }
	                );
	            }
	        }
	
	        NodeList nl = currentNode.getChildNodes();
	
	        for (int i = 0; i < nl.getLength(); i++) {
	            parseDocument(nl.item(i));
	        }
	    	}
	    	finally {
	    		try{mutex.release();}catch(Throwable ignore){}
	    	}
    }
1198472
function TagList(props: Props): React.Node {
  const { children, className } = props;
  const classes = cn("tags", className);
  return <div className={classes}>{children}</div>;
}
356502
public <T extends Tag> T get(String tagName) {
        return (T) this.value.get(tagName);
    }
74282
def _parseTagName(self):
        
        for el in self._element.split():
            el = el.replace("/", "").replace("<", "").replace(">", "")

            if el.strip():
                self._tagname = el.rstrip()
                return
378075
public <T extends Tag> T remove(String tagName) {
        return (T) this.value.remove(tagName);
    }
331414
public static function getElementsByTagName($node, $tagName)
    {
        $ret = array();
        $nodes = $node->getElementsByTagName($tagName);
        foreach ($nodes as $node) {
            if ($node instanceof DOMElement) {
                array_push($ret, $node);
            }
        }
        return $ret;
    }
102109
def GetNSAndWsdlname(self, tag):
      
      idx = tag.find(":")
      if idx >= 0:
         prefix, name = tag[:idx], tag[idx + 1:]
      else:
         prefix, name = None, tag
      # Map prefix to ns
      ns = self._GetNamespaceFromPrefix(prefix)
      return ns, name
1229611
def ns(self, prefix, tag):
        
        return etree.QName(self.prefixes[prefix], tag)
1319610
public DynaTreeNode getDomainTree(String domainName) {
        DynaTreeNode domainNode = new DynaTreeNode()
                .setTitle(domainName)
                .setKey(domainName)
                .setMode(MODE_DOMAIN);
        try {
            // List all objects in the domain
            ObjectName name = new ObjectName(domainName + ":*");
            Set<ObjectName> objs = mBeanServer.queryNames(name, null);
            
            // Convert object naems to a tree
            for (ObjectName objName : objs) {
                MBeanInfo info = mBeanServer.getMBeanInfo(objName);
                Matcher m = csvRE.matcher(objName.getKeyPropertyListString());
                
                DynaTreeNode node = domainNode;
                StringBuilder innerKey = new StringBuilder();
                innerKey.append(domainName).append(":");
                
                while (m.find()) {
                    String title = StringUtils.removeEnd(m.group(), ",");
                    String key   = StringUtils.substringBefore(title, "=");
                    String value = StringUtils.substringAfter(title, "=");
                    value = StringUtils.removeStart(value, "\"");
                    value = StringUtils.removeEnd  (value, "\"");
                    
                    innerKey.append(title).append(",");
                    
                    DynaTreeNode next = node.getChild(value);
                    if (next == null) {
                        next = new DynaTreeNode()
                            .setTitle(value)
                            .setMode(MODE_INNER)
                            .setKey(innerKey.toString() + "*")
                            .setNoLink(false);
                        node.putChild(next);
                    }
                    node = next;
                }
                
                node.setKey(objName.getCanonicalName())
                    .setMode(MODE_LEAF);

                if (   info.getAttributes() != null
                    || info.getOperations() != null
                    || info.getNotifications() != null) {
                    node.setNoLink(false);
                }  
            }
        } catch (MalformedObjectNameException e) {
            LOG.error("Exception in getDomainTree ", e);
        } catch (IntrospectionException e) {
            LOG.error("Exception in getDomainTree ", e);
        } catch (ReflectionException e) {
            LOG.error("Exception in getDomainTree ", e);
        } catch (InstanceNotFoundException e) {
            LOG.error("Exception in getDomainTree ", e);
        } catch (RuntimeException e) {
            LOG.error("Exception in getDomainTree ", e);
        }
        return domainNode;
    }
1099711
protected DCTree blockTag() {
        int p = bp;
        try {
            nextChar();
            if (isIdentifierStart(ch)) {
                Name name = readTagName();
                TagParser tp = tagParsers.get(name);
                if (tp == null) {
                    List<DCTree> content = blockContent();
                    return m.at(p).UnknownBlockTag(name, content);
                } else {
                    switch (tp.getKind()) {
                        case BLOCK:
                            return tp.parse(p);
                        case INLINE:
                            return erroneous("dc.bad.inline.tag", p);
                    }
                }
            }
            blockContent();

            return erroneous("dc.no.tag.name", p);
        } catch (ParseException e) {
            blockContent();
            return erroneous(e.getMessage(), p);
        }
    }
1008039
public Tag findTag(String tagName)
    {
        if (null == tagName)
            throw new IllegalArgumentException("Looking for null tag name.");
        return definedTags.get(Tag.normalizeName(tagName));
    }
207852
public Configuration create(Document dc) {
        // Create configuration
        Configuration configuration = new Configuration();

        parseNesting(configuration, dc);

        // Parse parameters
        configuration.setParams(parseParams(dc));

        // Parse prefix and suffix
        configuration.setPrefix(parseFix(dc, TAG_PREFIX));
        configuration.setSuffix(parseFix(dc, TAG_SUFFIX));

        // Parse codes and scope and set this to configuration
        // Parse scopes
        NodeList scopeNodeList = dc.getDocumentElement().getElementsByTagNameNS(SCHEMA_LOCATION, TAG_SCOPE);
        Map<String, Scope> scopes = parseScopes(scopeNodeList);

        boolean fillRoot = false;
        Scope root;
        if (!scopes.containsKey(Scope.ROOT)) {
            root = new Scope(Scope.ROOT);
            scopes.put(Scope.ROOT, root);
            fillRoot = true;
        } else {
            root = scopes.get(Scope.ROOT);
        }

        // Parse codes
        Map<String, Code> codes = parseCodes(dc, scopes);

        // include codes in scopes
        fillScopeCodes(scopeNodeList, scopes, codes);

        // If root scope not defined in configuration file, then root scope fills all codes
        if (fillRoot) {
            root.setCodes(new HashSet<Code>(codes.values()));
        }

        // set root scope
        configuration.setRootScope(root);

        // return configuration
        return configuration;
    }
1190610
private void parseNesting(Configuration configuration, Document dc) {
        NodeList list = dc.getElementsByTagNameNS(SCHEMA_LOCATION, TAG_NESTING);
        if (list.getLength() > 0) {
            Node el = list.item(0);
            configuration.setNestingLimit(nodeAttribute(el, TAG_NESTING_ATTR_LIMIT, Configuration.DEFAULT_NESTING_LIMIT));
            configuration.setPropagateNestingException(
                    nodeAttribute(el, TAG_NESTING_ATTR_EXCEPTION, Configuration.DEFAULT_PROPAGATE_NESTING_EXCEPTION)
            );
        }
    }
580551
function parse(xml) {
    var parser = domParserArg ? new dom.DOMParser(domParserArg) : new dom.DOMParser();
    var doc;
    try {
        doc = parser.parseFromString(xml, 'application/xml');
    } catch (e) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + e.message);
    }
    if (!doc.documentElement) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml');
    }
    var parserError = doc.getElementsByTagName('parsererror')[0];
    if (parserError) {
        throw new KdbxError(Consts.ErrorCodes.FileCorrupt, 'bad xml: ' + parserError.textContent);
    }
    return doc;
}
4667
function parseXML(xml) {
		if ( window.DOMParser == undefined && window.ActiveXObject ) {
			DOMParser = function() { };
			DOMParser.prototype.parseFromString = function( xmlString ) {
				var doc = new ActiveXObject('Microsoft.XMLDOM');
				doc.async = 'false';
				doc.loadXML( xmlString );
				return doc;
			};
		}

		try {
			var xmlDoc = ( new DOMParser() ).parseFromString( xml, 'text/xml' );
			if ( $.isXMLDoc( xmlDoc ) ) {
				var err = $('parsererror', xmlDoc);
				if ( err.length == 1 ) {
					throw new Error('Error: ' + $(xmlDoc).text() );
				}
			} else {
				throw new Error('Unable to parse XML');
			}
			return xmlDoc;
		} catch( e ) {
			var msg = ( e.name == undefined ? e : e.name + ': ' + e.message );
			$(document).trigger('xmlParseError', [ msg ]);
			return undefined;
		}
	}