Package io.github.the_sdet.xml
Class XMLUtils
java.lang.Object
io.github.the_sdet.xml.XMLUtils
This class handles all JSON related Utilities and Helper methods
- Author:
- Pabitra Swain ([email protected])
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddeleteXMLNode(Document doc, String elementXpath) Deletes an XML node identified by its XPath.static StringgetContentFromXmlResponse(String response, String regex) Extracts content from an XML response using a regular expression.static DocumentReads an XML file and returns a Document object representing its structure.static voidSaves an XML document to a file.static voidupdateXMLData(Document doc, String elementXpath, String value) Updates the value of an XML element identified by its XPath.
-
Constructor Details
-
XMLUtils
public XMLUtils()
-
-
Method Details
-
readXML
Reads an XML file and returns a Document object representing its structure.- Parameters:
filePath- The path to the XML file to be read.- Returns:
- A Document object representing the XML structure.
- Throws:
Exception- if an error occurs during parsing or reading the file.
-
saveXML
Saves an XML document to a file.- Parameters:
doc- The Document object representing the XML structure.filePath- The path to the file where the XML document will be saved.- Throws:
Exception- if an error occurs during the transformation or writing to the file.
-
updateXMLData
Updates the value of an XML element identified by its XPath.- Parameters:
doc- The Document object representing the XML structure.elementXpath- The XPath expression to identify the XML element.value- The new value to set for the XML element.- Throws:
Exception- if an error occurs during XPath evaluation or updating the XML element.
-
deleteXMLNode
Deletes an XML node identified by its XPath.- Parameters:
doc- The Document object representing the XML structure.elementXpath- The XPath expression to identify the XML node.- Throws:
Exception- if an error occurs during XPath evaluation or deleting the XML node.
-
getContentFromXmlResponse
Extracts content from an XML response using a regular expression.- Parameters:
response- The XML response string.regex- The regular expression to match the content.- Returns:
- The content extracted from the XML response.
-