List of usage examples for org.w3c.dom Document createAttribute
public Attr createAttribute(String name) throws DOMException;
Attr
of the given name. From source file:Main.java
public static void addAttribute(Document doc, Element node, String name, String value) { Attr attribute = doc.createAttribute(name); attribute.setValue(value);/*w w w . ja v a 2 s . c om*/ node.getAttributes().setNamedItem(attribute); }
From source file:Main.java
public static void addAttribute(Document document, Node parent, String attrName, String value) { Attr attr = document.createAttribute(attrName); attr.setValue(value);//from w w w .ja v a 2 s.c o m NamedNodeMap map = parent.getAttributes(); map.setNamedItem(attr); }
From source file:Main.java
/** * Adds the attribute to the given node/*from www .j ava2 s . c o m*/ * @param doc * @param node * @param attrName * @param attrValue */ public static void addAttr(Document doc, Node node, String attrName, Object attrValue) { Node attr = doc.createAttribute(attrName); attr.setNodeValue(attrValue.toString()); node.getAttributes().setNamedItem(attr); }
From source file:Main.java
public static void addAttribute(Document doc, String name, Element e, String value) { Node attrNode = doc.createAttribute(name); attrNode.setNodeValue(value);//www . j a v a2s. co m NamedNodeMap attrs = e.getAttributes(); attrs.setNamedItem(attrNode); }
From source file:Main.java
public static void addAttribute(Document document, Node node, String attName, String attValue) { Attr attr = document.createAttribute(attName); attr.setNodeValue(removeXMLInvalidChars(attValue)); node.getAttributes().setNamedItem(attr); }
From source file:Main.java
/** * Sets an attribute./*w w w .j a v a 2 s . c o m*/ * * @param doc document * @param node parent node * @param name name of attribute * @param text value of attribute * @return attribute object */ public static Attr setAttr(Document doc, Element node, String name, String text) { Attr attr = doc.createAttribute(name); attr.setValue(text); return node.setAttributeNode(attr); }
From source file:Main.java
public static void addAttribute(Document doc, Node parentNode, String name, String content) { Attr attNode = doc.createAttribute(name); attNode.setNodeValue(content);//from w ww .j a va2 s.c o m parentNode.getAttributes().setNamedItem(attNode); }
From source file:Main.java
public static void addAttribute(Document xmlDoc, Node node, String attrName, String attrValue) { Attr newAtt = xmlDoc.createAttribute(attrName); newAtt.setNodeValue(attrValue);// w w w .j av a 2 s.c om NamedNodeMap attrs = node.getAttributes(); attrs.setNamedItem(newAtt); }
From source file:Main.java
public static Attr createAttribute(String name) { Attr attribute = null;//from www .j a v a 2 s.co m Document document = createDocument(); if (document != null) { attribute = document.createAttribute(name); } return attribute; }
From source file:Main.java
private static Element populateRootElement(Document doc, Element item) { // set attribute to root element Attr attr = doc.createAttribute("xmlns:xsi"); attr.setValue("http://www.w3.org/2001/XMLSchema-instance"); item.setAttributeNode(attr);/*from w ww. j a va2s. c o m*/ attr = doc.createAttribute("xmlns"); attr.setValue("http://www.example.com/airlines"); item.setAttributeNode(attr); attr = doc.createAttribute("xsi:schemaLocation"); attr.setValue("http://www.example.com/airlines airline.xsd"); item.setAttributeNode(attr); /** * TODO Do the same for root element */ return item; }