| java.lang.Object com.knowgate.dataxslt.XMLDocument
XMLDocument | public class XMLDocument (Code) | | Direct character-level manipulations for XML documents.
This class modifies XML document files by directy seeking substrings inside
its text. Given a well-knonw XML file structure is easier and faster to seek
for <nodes> as substrings instead of parsing the whole documents into a
DOM tree.
author: Sergio Montoro Ten version: 2.2 |
Constructor Summary | |
public | XMLDocument() | public | XMLDocument(String sFile) Create XMLDocument and load an XML file into memory.
No node parsing is done, but file is loaded directly into a String. | public | XMLDocument(String sFile, String sEnc) Create XMLDocument and load an XML file into memory. |
XMLDocument | public XMLDocument()(Code) | | |
addNode | public void addNode(String sAfterXPath, String sNode) throws DOMException(Code) | | Add a piece of XML text after a given node identifier by an XPath expression.
Parameters: sAfterXPath - Restricted XPath expression for node after witch the next node is to be placed.For example : "pageset/pages/page[@guid="123456789012345678901234567890AB"]/blocks/block[@id="003"]" will add sNode text after ... substring. "pageset/pages/page[position()=last()]" will add sNode text after last ... substring. Parameters: sNode - XML Text to be added. throws: 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 |
|
addNodeAndSave | public void addNodeAndSave(String sAfterXPath, String sNode) throws DOMException, IOException(Code) | | Add a piece of XML text after a given node and save document.
Document is saved to the same file path where if was loaded.
Parameters: sAfterXPath - Restricted XPath expression for node after witch the next node is to be placed. Parameters: sNode - XML Text to be added. throws: DOMException - throws: IOException - |
getCharacterEncoding | public String getCharacterEncoding()(Code) | | |
load | public void load(String sFile) throws IOException, OutOfMemoryError(Code) | | Load an XML file into memory.
No node parsing is done, but file is loaded directly into a String.
Character encoding is UTF-8 by default unless changed by calling setEncoding()
Parameters: sFile - File Path throws: IOException - throws: OutOfMemoryError - |
removeNode | public void removeNode(String sXPath) throws DOMException(Code) | | Remove a node.
Parameters: sXPath - Restricted XPath expression for node to remove.For example: "pageset/pages/page[@guid="123456789012345678901234567890AB"]/blocks/block[@id="003"]"will remove ... substring. throws: DOMException - |
removeNodeAndSave | public void removeNodeAndSave(String sXPath) throws DOMException, IOException(Code) | | Remove a node and save document.
Document is saved to the same file path where if was loaded.
Parameters: sXPath - XPath expression for node to remove. throws: DOMException - throws: IOException - |
setCharacterEncoding | public void setCharacterEncoding(String sEnc)(Code) | | |
toString | public String toString()(Code) | | Get loaded file as a String
|
|
|