Package sk.iway.iwcm

Class XmlUtils

java.lang.Object
sk.iway.iwcm.XmlUtils

public class XmlUtils extends Object
XmlUtils.java - pomocne metody pre pracu s XML
  • Constructor Details

    • XmlUtils

      protected XmlUtils()
  • Method Details

    • getAttribute

      public static String getAttribute(Node node, String attrname)
    • getText

      public static String getText(Node node, boolean concatenate)
    • getText

      public static String getText(Node node)
    • getText

      public static String getText(Node node, String defaultValue)
    • getText

      public static String getText(Node node, String defaultValue, boolean concatenate)
    • getCDATA

      public static String getCDATA(Node node)
    • addText

      public static Text addText(Node node, String text)
    • addCDATA

      public static void addCDATA(Node node, String text)
    • setText

      public static Text setText(Node node, String text)
    • setCDATA

      public static void setCDATA(Node node, String text)
    • getDouble

      public static double getDouble(Node node, double defaultValue)
    • getInt

      public static int getInt(Node node, int defaultValue)
    • getChildNodes

      public static Vector<Node> getChildNodes(Node parent, short type)
    • removeChildNodes

      public static void removeChildNodes(Node node, short type)
    • removeAllChildren

      public static void removeAllChildren(Node node)
    • getChildNodes

      public static Vector<Node> getChildNodes(Node parent, String tagName)
    • removeChildNodes

      public static Vector<Node> removeChildNodes(Node node, String name)
    • getNodesWithAttribute

      public static Vector<Element> getNodesWithAttribute(Node node, String attributeName, String attributeValue)
    • getNodesWithAttribute

      public static Vector<Element> getNodesWithAttribute(NodeList nl, String attributeName, String attributeValue)
    • swapNodes

      public static void swapNodes(Node aNode, Node bNode)
    • getSameNameSiblings

      public static Vector<Node> getSameNameSiblings(Node node)
    • addNode

      public static Element addNode(Node parent, String tagName)
    • addNode

      public static Element addNode(Node parent, String tagName, String value)
    • getFirstChild

      public static Node getFirstChild(Node parent, String tagName)
    • getFirstChildValue

      public static String getFirstChildValue(Node node, String tagName)
    • hasNonTextChild

      public static boolean hasNonTextChild(Node node)
    • createSimpleElement

      public static Node createSimpleElement(Document doc, String name, boolean value)
    • createSimpleElement

      public static Node createSimpleElement(Document doc, String name, int value)
    • createSimpleElement

      public static Node createSimpleElement(Document doc, String name, double value)
    • createSimpleElement

      public static Node createSimpleElement(Document doc, String name, String value)
    • nodeToBoolean

      public static boolean nodeToBoolean(Node node)
      Returns the value of the given node as a boolean
    • addAttr

      public static void addAttr(Element parent, String name, String value)
      Adds an attribute with the specified name to the given element only if the value parameter is not null.
    • getAttribute

      public static String getAttribute(Node node, String attribute, String defaultValue)
    • getAttributeUp

      public static String getAttributeUp(Node node, String attribute)
    • hasElementWithValue

      public static boolean hasElementWithValue(Node parent, String tagName, String value)
    • getElementsWithValue

      public static Vector<Node> getElementsWithValue(Node parent, String tagName, String value)
    • getIntAttributeFromValue

      protected static int getIntAttributeFromValue(Node node, String value, int defaultValue)
    • getIntAttributeUp

      public static int getIntAttributeUp(Node node, String attribname, int defaultValue)
    • getIntAttribute

      public static int getIntAttribute(Node node, String attribname, int defaultValue)
    • getBooleanAttributeFromValue

      protected static boolean getBooleanAttributeFromValue(Node node, String value, boolean defaultValue)
    • getBooleanAttributeUp

      public static boolean getBooleanAttributeUp(Node node, String attribname, boolean defaultValue)
    • getBooleanAttribute

      public static boolean getBooleanAttribute(Node node, String attribname, boolean defaultValue)
    • getChildPos

      public static int getChildPos(Node parent, Node child)
    • copyNode

      public static void copyNode(Node source, Node dest)
      recursively copies the source node to the destination
    • copyNode

      public static void copyNode(Node source, Node dest, boolean copyAttributes)
      recursively copies the source node to the destination
    • getChildNodeByPath

      public static Node getChildNodeByPath(Node source, String path)
    • getChildNodesByPath

      public static Vector<Node> getChildNodesByPath(Node source, String path)
    • normalizeAndPrint

      public static String normalizeAndPrint(String s)
    • normalizeAndPrint

      protected static void normalizeAndPrint(PrintWriter fOut, char c, boolean fCanonical)
      Normalizes and print the given character.
    • readDocument

      public static Document readDocument(String url) throws Exception
      Vrati objekt typu Document zo zadaneho URL (lokalne)
      Parameters:
      url -
      Returns:
      Throws:
      Exception
    • saveDocument

      public static boolean saveDocument(Document doc, String url, String encoding) throws Exception
      Ulozi objekt typu Document na zadane URL (lokalne)
      Parameters:
      doc -
      url -
      encoding -
      Returns:
      Throws:
      Exception
    • getTextFromNode

      public static String getTextFromNode(String tagName, Element el)
      Funkcia, ktora ziska text z xml tagu tagName v elemente el.
      Parameters:
      tagName - Nazov tagu, z ktoreho chceme vytiahnut text
      el - Element, v ktorom sa nachadza dany tag
      Returns:
      Vrati text, ktory sa nachadza v danom retazci. Ak nastane hocijaka chyba, vrati prazdny retazec.