Java XML Attribute Add addAttributeToXPathExpression(Node nodeAttr, String xpathExpression, String and)

Here you can find the source of addAttributeToXPathExpression(Node nodeAttr, String xpathExpression, String and)

Description

add Attribute To X Path Expression

License

Apache License

Parameter

Parameter Description
nodeAttr a parameter
xpathExpression a parameter
and a parameter

Declaration

private static String addAttributeToXPathExpression(Node nodeAttr, String xpathExpression, String and) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Node;

public class Main {
    /**// www. j  a  v  a  2 s .  c o m
     * 
     * @param nodeAttr
     * @param xpathExpression
     * @param and
     * @return
     */
    private static String addAttributeToXPathExpression(Node nodeAttr, String xpathExpression, String and) {

        // si no esta vacio el atributo
        String value = nodeAttr.getNodeValue();
        xpathExpression = xpathExpression + and + "@" + nodeAttr.getNodeName() + "='" + value + "'";

        return xpathExpression;
    }

    private static String addAttributeToXPathExpression(String attribute, String value, String xpathExpression,
            String and) {

        // si no esta vacio el atributo
        xpathExpression = xpathExpression + and + "@" + attribute + "='" + value + "'";

        return xpathExpression;
    }
}

Related

  1. addAttribute(final Node e, final String name, final String value)
  2. addAttribute(final Node node, final Attr attribute)
  3. addAttribute(Node parent, String name, String value)
  4. addAttribute(Node pNode, String attrName, String attrValue)
  5. addAttributes(Element element, String[][] attributes)
  6. addDomAttr(Document doc, String tagName, String tagNamespaceURI, String attrName, String attrValue)
  7. addDoubleAttributeAsInteger(Element element, String attName, double value)
  8. addElement(Node parent, String name, Attr[] attrs)
  9. addElementAndAttributes(Node parent, String name, String[] atts)