Package sk.iway.iwcm
Class XmlUtils
java.lang.Object
sk.iway.iwcm.XmlUtils
XmlUtils.java - pomocne metody pre pracu s XML
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Adds an attribute with the specified name to the given element only if thevalue
parameter is notnull
.static void
static Element
static Element
static Text
static void
recursively copies the source node to the destinationstatic void
recursively copies the source node to the destinationstatic Node
createSimpleElement
(Document doc, String name, boolean value) static Node
createSimpleElement
(Document doc, String name, double value) static Node
createSimpleElement
(Document doc, String name, int value) static Node
createSimpleElement
(Document doc, String name, String value) static String
getAttribute
(Node node, String attrname) static String
getAttribute
(Node node, String attribute, String defaultValue) static String
getAttributeUp
(Node node, String attribute) static boolean
getBooleanAttribute
(Node node, String attribname, boolean defaultValue) protected static boolean
getBooleanAttributeFromValue
(Node node, String value, boolean defaultValue) static boolean
getBooleanAttributeUp
(Node node, String attribname, boolean defaultValue) static String
static Node
getChildNodeByPath
(Node source, String path) getChildNodes
(Node parent, short type) getChildNodes
(Node parent, String tagName) getChildNodesByPath
(Node source, String path) static int
getChildPos
(Node parent, Node child) static double
getElementsWithValue
(Node parent, String tagName, String value) static Node
getFirstChild
(Node parent, String tagName) static String
getFirstChildValue
(Node node, String tagName) static int
static int
getIntAttribute
(Node node, String attribname, int defaultValue) protected static int
getIntAttributeFromValue
(Node node, String value, int defaultValue) static int
getIntAttributeUp
(Node node, String attribname, int defaultValue) getNodesWithAttribute
(NodeList nl, String attributeName, String attributeValue) getNodesWithAttribute
(Node node, String attributeName, String attributeValue) getSameNameSiblings
(Node node) static String
static String
static String
static String
static String
getTextFromNode
(String tagName, Element el) Funkcia, ktora ziska text z xml tagu tagName v elemente el.static boolean
hasElementWithValue
(Node parent, String tagName, String value) static boolean
hasNonTextChild
(Node node) static boolean
nodeToBoolean
(Node node) Returns the value of the given node as a booleanprotected static void
normalizeAndPrint
(PrintWriter fOut, char c, boolean fCanonical) Normalizes and print the given character.static String
static Document
readDocument
(String url) Vrati objekt typu Document zo zadaneho URL (lokalne)static void
removeAllChildren
(Node node) static void
removeChildNodes
(Node node, short type) removeChildNodes
(Node node, String name) static boolean
saveDocument
(Document doc, String url, String encoding) Ulozi objekt typu Document na zadane URL (lokalne)static void
static Text
static void
-
Constructor Details
-
XmlUtils
protected XmlUtils()
-
-
Method Details
-
getAttribute
-
getText
-
getText
-
getText
-
getText
-
getCDATA
-
addText
-
addCDATA
-
setText
-
setCDATA
-
getDouble
-
getInt
-
getChildNodes
-
removeChildNodes
-
removeAllChildren
-
getChildNodes
-
removeChildNodes
-
getNodesWithAttribute
-
getNodesWithAttribute
-
swapNodes
-
getSameNameSiblings
-
addNode
-
addNode
-
getFirstChild
-
getFirstChildValue
-
hasNonTextChild
-
createSimpleElement
-
createSimpleElement
-
createSimpleElement
-
createSimpleElement
-
nodeToBoolean
Returns the value of the given node as a boolean -
addAttr
Adds an attribute with the specified name to the given element only if thevalue
parameter is notnull
. -
getAttribute
-
getAttributeUp
-
hasElementWithValue
-
getElementsWithValue
-
getIntAttributeFromValue
-
getIntAttributeUp
-
getIntAttribute
-
getBooleanAttributeFromValue
-
getBooleanAttributeUp
-
getBooleanAttribute
-
getChildPos
-
copyNode
recursively copies the source node to the destination -
copyNode
recursively copies the source node to the destination -
getChildNodeByPath
-
getChildNodesByPath
-
normalizeAndPrint
-
normalizeAndPrint
Normalizes and print the given character. -
readDocument
Vrati objekt typu Document zo zadaneho URL (lokalne)- Parameters:
url
-- Returns:
- Throws:
Exception
-
saveDocument
Ulozi objekt typu Document na zadane URL (lokalne)- Parameters:
doc
-url
-encoding
-- Returns:
- Throws:
Exception
-
getTextFromNode
Funkcia, ktora ziska text z xml tagu tagName v elemente el.- Parameters:
tagName
- Nazov tagu, z ktoreho chceme vytiahnut textel
- Element, v ktorom sa nachadza dany tag- Returns:
- Vrati text, ktory sa nachadza v danom retazci. Ak nastane hocijaka chyba, vrati prazdny retazec.
-