Package com.mycila.xmltool
Class XMLDoc
java.lang.Object
com.mycila.xmltool.XMLDoc
- All Implemented Interfaces:
XMLTag
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute
(String name, String value) Create a new attribute for the current nodeaddAttribute
(Attr attr) Add given attribute to current elementAdd a data node under the current node, and jump to the parent node.addCDATA
(CDATASection data) Add a CDATA note to the current tagaddDocument
(XMLTag tag) Inserts anotherXMLTag
instance under the current tag.addDocument
(Document doc) Inserts anotherDocument
instance under the current tagaddNamespace
(String prefix, String namespaceURI) Add a namespace to the documentInserts anotherXMLTag
tag hierarchy under the current tag.Create a tag under the current location and use it as the current nodeInserts aElement
instance and its hierarchy under the current tagAdd a text node under the current node, and jump to the parent node.Add a text note to the current tagchilds
(short type) delete()
Delete current tag and its childs.deleteAttribute
(String name) Delete an attribute of the current node.Delete an attribute of the current node, if it existsDelete all existing attributes of current nodeDelete all existing elements of this nodeRemove any prefix and namespaces contained in the tag name, childs and attributes, thus changing namespace and tag name.findAttribute
(String name) returns the attribute value of the current node or null if the attribute does not existfindAttribute
(String name, String relativeXpath, Object... arguments) Returns the attribute value of the node pointed by given XPath expression or null if the attribute does not existExecute an action for each selected tags from the current node.forEachChild
(CallBack callBack) Execute an action for each child in the current node.static XMLTag
static XMLTag
static XMLTag
from
(InputStream is, boolean ignoreNamespaces) static XMLTag
static XMLTag
static XMLTag
static XMLTag
static XMLTag
static XMLTag
from
(InputSource source, boolean ignoreNamespaces) static XMLTag
fromCurrentTag
(XMLTag tag, boolean ignoreNamespaces) Create anotherXMLTag
instance from the hierarchy under the current tag.getAttribute
(String name) returns the attribute value of the current nodegetAttribute
(String name, String relativeXpath, Object... arguments) Returns the attribute value of the node pointed by given XPath expressionString[]
getCDATA()
Get the CDATA of a selected nodegetCDATAorText
(String relativeXpath, Object... arguments) Get the text of a sepcific nodeint
XMLTag tag = XMLDoc.newDocument(true) .addRoot("root").addTag("a") .gotoParent().addTag("b") .gotoParent().addTag("c") .gotoRoot(); assertEquals(tag.getCurrentTagName(), "root"); for (XMLTag xmlTag : tag.getChilds()) { if(xmlTag.getCurrentTagName().equals("b")) { break; } } assertEquals(tag.getCurrentTagName(), "b");
Create an iterable object over selected elements.Get the prefix of a namespaceString[]
getPefixes
(String namespaceURI) Get all bound prefixes of a namespacegetText()
Get the text of a sepcific nodegetTextOrCDATA
(String relativeXpath, Object... arguments) Get the text of a sepcific nodeGo to the only child element of the curent node.gotoChild
(int i) Go to the Nth child of the curent node.Go to the child found with given node nameGo to the first child element of the curent node.gotoFirstChild
(String name) Go to the first child occurance found having given nameGo to the lastest child element of the curent node.gotoLastChild
(String name) Go to the last child occurance found having given nameGo to parent tag.gotoRoot()
Go to document root tagGo to a specific nodeboolean
hasAttribute
(String name) Check wheter current tag contains an atributeboolean
hasAttribute
(String name, String relativeXpath, Object... arguments) Check if targeted tag has an attribute of given nameboolean
Check if a tag exist in the documentprivate boolean
static XMLDocBuilder
newDocument
(boolean ignoreNamespaces) rawXpathBoolean
(String relativeXpath, Object... arguments) Execute an XPath expression directly using the Java XPath API, from the current node.rawXpathNode
(String relativeXpath, Object... arguments) Execute an XPath expression directly using the Java XPath API, from the current node.rawXpathNodeSet
(String relativeXpath, Object... arguments) Execute an XPath expression directly using the Java XPath API, from the current node.rawXpathNumber
(String relativeXpath, Object... arguments) Execute an XPath expression directly using the Java XPath API, from the current node.rawXpathString
(String relativeXpath, Object... arguments) Execute an XPath expression directly using the Java XPath API, from the current node.Replace current element name by another namesetAttribute
(String name, String value) Sets the new value on an existign attribute, and remains on the current tag.setAttribute
(String name, String value, String relativeXpath, Object... arguments) Sets the new value on a targetted node's attribute, and remains on the current tag.setAttributeIfExist
(String name, String value) Sets the new value on an attribute, and remains on the current tag.setAttributeIfExist
(String name, String value, String relativeXpath, Object... arguments) Sets the new value on a targetted node's attribute, and remains on the current tag.Set the cdata in the current node.Set the cdata in the targetted node.setCDATAIfExist
(String data, String relativeXpath, Object... arguments) Set the cdata in the targetted node.Set the text in the current node.Set the text in the targetted node.setTextIfExist
(String text, String relativeXpath, Object... arguments) Set the text in the targetted node.byte[]
toBytes()
byte[]
toOutputStream
(String encoding) toResult()
Converts this document to the result providedConverts this document to the result provided, overriding default encoding of xml documenttoSource()
toStream
(OutputStream out) Write this document to a streamtoStream
(OutputStream out, String encoding) Write this document to a streamWrite this document to a streamWrite this document to a streamtoString()
toWriter()
Validate this document against specifief schemasValidate this document against specifief schemas
-
Field Details
-
definition
-
current
Element current
-
-
Constructor Details
-
XMLDoc
XMLDoc(XMLDocDefinition definition)
-
-
Method Details
-
getContext
- Specified by:
getContext
in interfaceXMLTag
- Returns:
- the namespace context
-
hasAttribute
Description copied from interface:XMLTag
Check wheter current tag contains an atribute- Specified by:
hasAttribute
in interfaceXMLTag
- Parameters:
name
- Attribute name- Returns:
- true if the attribute is in current tag
-
hasAttribute
Description copied from interface:XMLTag
Check if targeted tag has an attribute of given name- Specified by:
hasAttribute
in interfaceXMLTag
- Parameters:
name
- the name of the attributerelativeXpath
- XPath that target the tagarguments
- optional arguments of xpath expression. Uses String.format() to build XPath expression.- Returns:
- true if the tag exist with this attribute name
-
hasTag
Description copied from interface:XMLTag
Check if a tag exist in the document -
forEachChild
Description copied from interface:XMLTag
Execute an action for each child in the current node.- Specified by:
forEachChild
in interfaceXMLTag
- Parameters:
callBack
- Callback method to run after the current tag of the document has changed to a child- Returns:
- this
-
forEach
Description copied from interface:XMLTag
Execute an action for each selected tags from the current node.- Specified by:
forEach
in interfaceXMLTag
- Parameters:
callBack
- Callback method to run after the current tag of the document has changed to a childrelativeXpath
- XXath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- this
-
forEach
-
rawXpathString
Description copied from interface:XMLTag
Execute an XPath expression directly using the Java XPath API, from the current node.- Specified by:
rawXpathString
in interfaceXMLTag
- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.STRING
return type
-
rawXpathNumber
Description copied from interface:XMLTag
Execute an XPath expression directly using the Java XPath API, from the current node.- Specified by:
rawXpathNumber
in interfaceXMLTag
- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.NUMBER
return type
-
rawXpathBoolean
Description copied from interface:XMLTag
Execute an XPath expression directly using the Java XPath API, from the current node.- Specified by:
rawXpathBoolean
in interfaceXMLTag
- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.BOOLEAN
return type
-
rawXpathNode
Description copied from interface:XMLTag
Execute an XPath expression directly using the Java XPath API, from the current node.- Specified by:
rawXpathNode
in interfaceXMLTag
- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.NODE
return type
-
rawXpathNodeSet
Description copied from interface:XMLTag
Execute an XPath expression directly using the Java XPath API, from the current node.- Specified by:
rawXpathNodeSet
in interfaceXMLTag
- Parameters:
relativeXpath
- The XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The
XPathConstants.NODESET
return type
-
getPefix
Description copied from interface:XMLTag
Get the prefix of a namespace -
getPefixes
Description copied from interface:XMLTag
Get all bound prefixes of a namespace- Specified by:
getPefixes
in interfaceXMLTag
- Parameters:
namespaceURI
- The URI of the namespace- Returns:
- a list of prefixes or an empty array.
-
addNamespace
Description copied from interface:XMLTag
Add a namespace to the document- Specified by:
addNamespace
in interfaceXMLTag
- Parameters:
prefix
- The prefix of the namespacenamespaceURI
- The URI of the namespace- Returns:
- this
-
addDocument
Description copied from interface:XMLTag
Inserts anotherXMLTag
instance under the current tag. The whole document will be inserted.- Specified by:
addDocument
in interfaceXMLTag
- Parameters:
tag
- TheXMLTag
instance to insert- Returns:
- this
-
addDocument
Description copied from interface:XMLTag
Inserts anotherDocument
instance under the current tag- Specified by:
addDocument
in interfaceXMLTag
- Parameters:
doc
- TheDocument
instance to insert- Returns:
- this
-
addTag
Description copied from interface:XMLTag
Inserts anotherXMLTag
tag hierarchy under the current tag. Only the current tag of the given document will be inserted with its hierarchy, not the whole document. -
addTag
Description copied from interface:XMLTag
Inserts aElement
instance and its hierarchy under the current tag -
addTag
Description copied from interface:XMLTag
Create a tag under the current location and use it as the current node -
addAttribute
Description copied from interface:XMLTag
Create a new attribute for the current node- Specified by:
addAttribute
in interfaceXMLTag
- Parameters:
name
- Name of the attribute to addvalue
- value of the attribute to add- Returns:
- this
-
addAttribute
Description copied from interface:XMLTag
Add given attribute to current element- Specified by:
addAttribute
in interfaceXMLTag
- Parameters:
attr
- The attribute to insert- Returns:
- this
-
addText
Description copied from interface:XMLTag
Add a text node under the current node, and jump to the parent node. This enables the create or quick documents like this:addTag("name").addText("Bob")addTag("sex").addText("M")addTag("age").addText("30")
<name>Bob</name><sex>M</sex><age>30</age>
-
addText
Description copied from interface:XMLTag
Add a text note to the current tag -
addCDATA
Description copied from interface:XMLTag
Add a data node under the current node, and jump to the parent node. This enables the create or quick documents like this:addTag("name").addCDATA("Bob")addTag("sex").addCDATA("M")addTag("age").addCDATA("30")
<name><![CDATA[Bob]]></name><sex><![CDATA[M]]></sex><age><![CDATA[30]]></age>
-
addCDATA
Description copied from interface:XMLTag
Add a CDATA note to the current tag -
delete
Description copied from interface:XMLTag
Delete current tag and its childs. If the current tag is the root tag of xml document, it cannot be delete. It can just be replaced. In this case, an exception is thrown -
deleteChilds
Description copied from interface:XMLTag
Delete all existing elements of this node- Specified by:
deleteChilds
in interfaceXMLTag
- Returns:
- this
-
deleteAttributes
Description copied from interface:XMLTag
Delete all existing attributes of current node- Specified by:
deleteAttributes
in interfaceXMLTag
- Returns:
- this
-
deleteAttribute
Description copied from interface:XMLTag
Delete an attribute of the current node.- Specified by:
deleteAttribute
in interfaceXMLTag
- Parameters:
name
- attribute name- Returns:
- this
-
deleteAttributeIfExists
Description copied from interface:XMLTag
Delete an attribute of the current node, if it exists- Specified by:
deleteAttributeIfExists
in interfaceXMLTag
- Parameters:
name
- attribute name- Returns:
- this
-
renameTo
Description copied from interface:XMLTag
Replace current element name by another name -
deletePrefixes
Description copied from interface:XMLTag
Remove any prefix and namespaces contained in the tag name, childs and attributes, thus changing namespace and tag name. This can be very useful if you are working in a document when you want to ignore namespaces, if you don't know the tag prefix- Specified by:
deletePrefixes
in interfaceXMLTag
- Returns:
- this
-
getInnerDocument
- Specified by:
getInnerDocument
in interfaceXMLTag
- Returns:
- Another XMLTag instance in which the current tag becomes de root element of the new document, and it contains all inner elements as in the previous document.
-
getInnerText
- Specified by:
getInnerText
in interfaceXMLTag
- Returns:
- The text representation of the inner nodes of the current node. The current node is outputed as the root element of inner tags.
-
gotoParent
Description copied from interface:XMLTag
Go to parent tag. Do nothing if we are already at root- Specified by:
gotoParent
in interfaceXMLTag
- Returns:
- this
-
gotoRoot
Description copied from interface:XMLTag
Go to document root tag -
gotoChild
Description copied from interface:XMLTag
Go to the only child element of the curent node. -
gotoChild
Description copied from interface:XMLTag
Go to the Nth child of the curent node. -
gotoChild
Description copied from interface:XMLTag
Go to the child found with given node name -
gotoFirstChild
Description copied from interface:XMLTag
Go to the first child element of the curent node.- Specified by:
gotoFirstChild
in interfaceXMLTag
- Returns:
- this
- Throws:
XMLDocumentException
- If the current node has no child at all
-
gotoFirstChild
Description copied from interface:XMLTag
Go to the first child occurance found having given name- Specified by:
gotoFirstChild
in interfaceXMLTag
- Parameters:
name
- Name of the child to go at- Returns:
- this
- Throws:
XMLDocumentException
- If the current node has no child at all
-
gotoLastChild
Description copied from interface:XMLTag
Go to the lastest child element of the curent node.- Specified by:
gotoLastChild
in interfaceXMLTag
- Returns:
- this
- Throws:
XMLDocumentException
- If the current node has no child at all
-
gotoLastChild
Description copied from interface:XMLTag
Go to the last child occurance found having given name- Specified by:
gotoLastChild
in interfaceXMLTag
- Parameters:
name
- Name of the child to go at- Returns:
- this
- Throws:
XMLDocumentException
- If the current node has no child at all
-
gotoTag
Description copied from interface:XMLTag
Go to a specific node -
getCurrentTag
- Specified by:
getCurrentTag
in interfaceXMLTag
- Returns:
- the current tag
-
getChildCount
public int getChildCount()- Specified by:
getChildCount
in interfaceXMLTag
- Returns:
- The number of child for the current tag
-
getChilds
Description copied from interface:XMLTag
XMLTag tag = XMLDoc.newDocument(true) .addRoot("root").addTag("a") .gotoParent().addTag("b") .gotoParent().addTag("c") .gotoRoot(); assertEquals(tag.getCurrentTagName(), "root"); for (XMLTag xmlTag : tag.getChilds()) { if(xmlTag.getCurrentTagName().equals("b")) { break; } } assertEquals(tag.getCurrentTagName(), "b");
XMLTag tag = XMLDoc.newDocument(true) .addRoot("root").addTag("a") .gotoParent().addTag("b") .gotoParent().addTag("c") .gotoRoot(); assertEquals(tag.getCurrentTagName(), "root"); for (XMLTag xmlTag : tag.getChilds()) { System.out.println(xmlTag.getCurrentTagName()); } assertEquals(tag.getCurrentTagName(), "root");
-
getChilds
Description copied from interface:XMLTag
Create an iterable object over selected elements. Act as the getChilds method: The current position of XMLTag is modified at each iteration. Thus, if you break in the iteration, the current position will not be the same as the position before. -
getChildElement
- Specified by:
getChildElement
in interfaceXMLTag
- Returns:
- The child element's list
-
getCurrentTagName
- Specified by:
getCurrentTagName
in interfaceXMLTag
- Returns:
- the current tag name
-
getCurrentTagLocation
- Specified by:
getCurrentTagLocation
in interfaceXMLTag
- Returns:
- An XPath expression representing the current tag location in the document. If you are in the root node and run gotoTag() giving this XPath expression, you will return to the current node.
-
getAttribute
Description copied from interface:XMLTag
returns the attribute value of the current node- Specified by:
getAttribute
in interfaceXMLTag
- Parameters:
name
- attribute name- Returns:
- attribute value
-
findAttribute
Description copied from interface:XMLTag
returns the attribute value of the current node or null if the attribute does not exist- Specified by:
findAttribute
in interfaceXMLTag
- Parameters:
name
- attribute name- Returns:
- attribute value or null if no attribute
-
getAttribute
Description copied from interface:XMLTag
Returns the attribute value of the node pointed by given XPath expression- Specified by:
getAttribute
in interfaceXMLTag
- Parameters:
name
- attribute namerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- attribute value
-
findAttribute
public String findAttribute(String name, String relativeXpath, Object... arguments) throws XMLDocumentException Description copied from interface:XMLTag
Returns the attribute value of the node pointed by given XPath expression or null if the attribute does not exist- Specified by:
findAttribute
in interfaceXMLTag
- Parameters:
name
- attribute namerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- the attribute value or null if the attribute does not exist
- Throws:
XMLDocumentException
- targetted node does not exist or XPath expression is invalid
-
getAttributeNames
- Specified by:
getAttributeNames
in interfaceXMLTag
- Returns:
- all attribute names of current node
-
getText
Description copied from interface:XMLTag
Get the text of a sepcific node -
getText
-
getTextOrCDATA
- Specified by:
getTextOrCDATA
in interfaceXMLTag
- Returns:
- The text content of the current node, if none tries to get the CDATA content, if none returns ""
-
getTextOrCDATA
Description copied from interface:XMLTag
Get the text of a sepcific node- Specified by:
getTextOrCDATA
in interfaceXMLTag
- Parameters:
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The text content of the current node, if none tries to get the CDATA content, if none returns ""
- Throws:
XMLDocumentException
- If the XPath expression is not valid or if the node does not exist
-
getCDATAorText
- Specified by:
getCDATAorText
in interfaceXMLTag
- Returns:
- The CDATA content of the current node, if none tries to get the text content, if none returns ""
-
getCDATAorText
Description copied from interface:XMLTag
Get the text of a sepcific node- Specified by:
getCDATAorText
in interfaceXMLTag
- Parameters:
relativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- The CDATA content of the current node, if none tries to get the text content, if none returns ""
- Throws:
XMLDocumentException
- If the XPath expression is not valid or if the node does not exist
-
getCDATA
Description copied from interface:XMLTag
Get the CDATA of a selected node -
getCDATA
-
toDocument
- Specified by:
toDocument
in interfaceXMLTag
- Returns:
- the Document
-
toSource
-
toString
-
toString
-
toBytes
public byte[] toBytes() -
toBytes
-
toStream
Description copied from interface:XMLTag
Write this document to a stream -
toStream
Description copied from interface:XMLTag
Write this document to a stream -
toStream
Description copied from interface:XMLTag
Write this document to a stream -
toStream
Description copied from interface:XMLTag
Write this document to a stream -
toResult
-
toResult
-
toOutputStream
- Specified by:
toOutputStream
in interfaceXMLTag
- Returns:
- A stream where the document has already been written into
-
toOutputStream
- Specified by:
toOutputStream
in interfaceXMLTag
- Parameters:
encoding
- The new encoding- Returns:
- A stream where the document has already been written into
-
toWriter
-
toWriter
-
toResult
Description copied from interface:XMLTag
Converts this document to the result provided -
toResult
Description copied from interface:XMLTag
Converts this document to the result provided, overriding default encoding of xml document -
validate
Description copied from interface:XMLTag
Validate this document against specifief schemas -
validate
Description copied from interface:XMLTag
Validate this document against specifief schemas -
isElement
-
childs
-
attr
-
childs
-
duplicate
-
setText
Description copied from interface:XMLTag
Set the text in the current node. This method will replace all existing text and cdata by the given text. Also Jump after to the parent node. This enables the quicly replace test on several nodes like this:gotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
-
setText
public XMLTag setText(String text, String relativeXpath, Object... arguments) throws XMLDocumentException Description copied from interface:XMLTag
Set the text in the targetted node. This method will replace all existing text and cdata by the given text, but remains on the current tag.- Specified by:
setText
in interfaceXMLTag
- Parameters:
text
- text to put under this noderelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- this
- Throws:
XMLDocumentException
- If the XPath expression is invalid or if the node does not exist
-
setTextIfExist
public XMLTag setTextIfExist(String text, String relativeXpath, Object... arguments) throws XMLDocumentException Description copied from interface:XMLTag
Set the text in the targetted node. This method will replace all existing text and cdata by the given text, but remains on the current tag. If the targetted node does not exist, do nothing.- Specified by:
setTextIfExist
in interfaceXMLTag
- Parameters:
text
- text to put under this noderelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- this
- Throws:
XMLDocumentException
- If the XPath expression is invalid
-
setCDATA
Description copied from interface:XMLTag
Set the cdata in the current node. This method will replace all existing text and cdata by the given cdata Also Jump after to the parent node. This enables the quicly replace test on several nodes like this:gotoChild("name").setText("Bob").gotoChild("sex").setText("M").gotoChild("age").setText("30")
<name>Bob</name><sex>M</sex><age>30</age>
-
setCDATA
public XMLTag setCDATA(String data, String relativeXpath, Object... arguments) throws XMLDocumentException Description copied from interface:XMLTag
Set the cdata in the targetted node. This method will replace all existing text and cdata by the given cdata, but remains on the current tag.- Specified by:
setCDATA
in interfaceXMLTag
- Parameters:
data
- text to put under this node in a cdata sectionrelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- this
- Throws:
XMLDocumentException
- If the XPath expression is invalid or if the node does not exist
-
setCDATAIfExist
public XMLTag setCDATAIfExist(String data, String relativeXpath, Object... arguments) throws XMLDocumentException Description copied from interface:XMLTag
Set the cdata in the targetted node. This method will replace all existing text and cdata by the given cdata, but remains on the current tag. If the targetted node does not exist, do nothing.- Specified by:
setCDATAIfExist
in interfaceXMLTag
- Parameters:
data
- text to put under this node in a cdata sectionrelativeXpath
- XPath expression that select the nodearguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- this
- Throws:
XMLDocumentException
- If the XPath expression is invalid
-
setAttribute
Description copied from interface:XMLTag
Sets the new value on an existign attribute, and remains on the current tag.- Specified by:
setAttribute
in interfaceXMLTag
- Parameters:
name
- attribute namevalue
- new attribute'svalue- Returns:
- attribute value
- Throws:
XMLDocumentException
- If the attribute does not exist
-
setAttributeIfExist
Description copied from interface:XMLTag
Sets the new value on an attribute, and remains on the current tag. If it does not exist, do nothing.- Specified by:
setAttributeIfExist
in interfaceXMLTag
- Parameters:
name
- attribute namevalue
- new attribute value- Returns:
- attribute value
-
setAttribute
public XMLTag setAttribute(String name, String value, String relativeXpath, Object... arguments) throws XMLDocumentException Description copied from interface:XMLTag
Sets the new value on a targetted node's attribute, and remains on the current tag.- Specified by:
setAttribute
in interfaceXMLTag
- Parameters:
name
- attribute namevalue
- new attribute's valuerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- attribute value
- Throws:
XMLDocumentException
- Attribute does not exist, targetted node does not exit, or XPath expression is invalid
-
setAttributeIfExist
public XMLTag setAttributeIfExist(String name, String value, String relativeXpath, Object... arguments) throws XMLDocumentException Description copied from interface:XMLTag
Sets the new value on a targetted node's attribute, and remains on the current tag. If the attribute does not exist, do nothing.- Specified by:
setAttributeIfExist
in interfaceXMLTag
- Parameters:
name
- attribute namevalue
- new attribute's valuerelativeXpath
- XPath expressionarguments
- facultative Xpath expression arguments. Uses String.format() to build XPath expression.- Returns:
- attribute value
- Throws:
XMLDocumentException
- XPath expression is invalid or targetted node does not exist
-
newDocument
-
from
-
from
-
from
-
from
-
from
-
from
-
from
-
from
-
from
-
fromCurrentTag
Create anotherXMLTag
instance from the hierarchy under the current tag. The current tag becomes the root tag.- Parameters:
tag
- The current XML Tag positionned to the new root tagignoreNamespaces
- Wheter to build a namespace aware document- Returns:
- The inner XMLTag instance
-