public class XMLDocument
extends java.lang.Object
Constructor and Description |
---|
XMLDocument() |
XMLDocument(java.lang.String sFile)
Create XMLDocument and load an XML file into memory.
|
XMLDocument(java.lang.String sFile,
java.lang.String sEnc)
Create XMLDocument and load an XML file into memory.
|
Modifier and Type | Method and Description |
---|---|
void |
addNode(java.lang.String sAfterXPath,
java.lang.String sNode)
Add a piece of XML text after a given node identifier by an XPath expression.
|
void |
addNodeAndSave(java.lang.String sAfterXPath,
java.lang.String sNode)
Add a piece of XML text after a given node and save document.
|
java.lang.String |
getCharacterEncoding() |
void |
load(java.lang.String sFile)
Load an XML file into memory.
|
void |
load(java.lang.String sFile,
java.lang.String sEnc)
Load an XML file into memory.
|
void |
removeNode(java.lang.String sXPath)
Remove a node.
|
void |
removeNodeAndSave(java.lang.String sXPath)
Remove a node and save document.
|
void |
save()
Save file to disk.
|
void |
save(java.lang.String sFile)
Save file to disk.
|
void |
setCharacterEncoding(java.lang.String sEnc) |
java.lang.String |
toString()
Get loaded file as a String
|
public XMLDocument()
public XMLDocument(java.lang.String sFile) throws java.io.IOException, java.lang.OutOfMemoryError
Create XMLDocument and load an XML file into memory.
No node parsing is done, but file is loaded directly into a String.sFile
- File Pathjava.io.IOException
java.lang.OutOfMemoryError
public XMLDocument(java.lang.String sFile, java.lang.String sEnc) throws java.io.IOException, java.lang.OutOfMemoryError
sFile
- File PathsEnc
- Character Encodingjava.io.IOException
java.lang.OutOfMemoryError
public java.lang.String getCharacterEncoding()
public void setCharacterEncoding(java.lang.String sEnc)
public void load(java.lang.String sFile, java.lang.String sEnc) throws java.io.IOException, java.lang.OutOfMemoryError
sFile
- File PathsEnc
- Character encodingjava.io.IOException
java.lang.OutOfMemoryError
public void load(java.lang.String sFile) throws java.io.IOException, java.lang.OutOfMemoryError
Load an XML file into memory.
No node parsing is done, but file is loaded directly into a String.sFile
- File Pathjava.io.IOException
java.lang.OutOfMemoryError
public void save(java.lang.String sFile) throws java.io.IOException
sFile
- File Pathjava.io.IOException
public void save() throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public void addNode(java.lang.String sAfterXPath, java.lang.String sNode) throws org.w3c.dom.DOMException
sAfterXPath
- Restricted XPath expression for node after witch the next node is to be placed.
For example : sNode
- XML Text to be added.org.w3c.dom.DOMException
- DOMException Codes:NOT_FOUND_ERR | A node or attribute from the XPath expression was not found |
INVALID_ACCESS_ERR | An attribute expression is invalid |
NOT_SUPPORTED_ERR | position() function was used but last() was not specified as value for it |
public void addNodeAndSave(java.lang.String sAfterXPath, java.lang.String sNode) throws org.w3c.dom.DOMException, java.io.IOException
sAfterXPath
- Restricted XPath expression for node after witch the next node is to be placed.sNode
- XML Text to be added.org.w3c.dom.DOMException
java.io.IOException
public void removeNode(java.lang.String sXPath) throws org.w3c.dom.DOMException
sXPath
- Restricted XPath expression for node to remove.
For example: "pageset/pages/page[@guid="123456789012345678901234567890AB"]/blocks/block[@id="003"]"
will remove org.w3c.dom.DOMException
public void removeNodeAndSave(java.lang.String sXPath) throws org.w3c.dom.DOMException, java.io.IOException
sXPath
- XPath expression for node to remove.org.w3c.dom.DOMException
java.io.IOException