Package com.pingidentity.sdk.xml
Class XmlHelper
java.lang.Object
com.pingidentity.sdk.xml.XmlHelper
A utility class to help with some common/basic XML manipulation tasks.
- Since:
- 8.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAsFirstChild(XmlObject target, XmlObject child) Adds child as the first child element of target.addAsLastChild(XmlObject target, XmlObject child) Adds child as the last child element of target.addToSaml2Extensions(XmlObject targetDocument, String xml) Adds the given xml to the Extensions element (creating the Extensions, if needed) of the SAML 2.0 protocol XML document.getChildren(XmlObject xmlObject) Returns all the child elements of the given xml.getFirstChild(XmlObject xmlObject) Returns the first child element of the given xml.Parses the xml string into an XmlObject.voidsetAttribute(XmlObject target, String attributeName, String attributeValue) Sets an attribute on the given xml elementvoidsetAttribute(XmlObject target, String attributeNamespace, String attributeName, String attributeValue) Sets an attribute on the given xml element
-
Constructor Details
-
XmlHelper
public XmlHelper()
-
-
Method Details
-
addToSaml2Extensions
Adds the given xml to the Extensions element (creating the Extensions, if needed) of the SAML 2.0 protocol XML document.- Parameters:
targetDocument- a SAML 2.0 protocol XML document (i.e. ResponseDocument or AuthnRequestDocument)xml- the XML to add to the Extensions- Returns:
- a reference to the XmlObject representing the newly added XML element, which can be further manipulated and the changes will be reflected in the SAML 2.0 protocol XML document
-
setAttribute
Sets an attribute on the given xml element- Parameters:
target- the xml element on which to set the attributeattributeName- name of the attributeattributeValue- value of the attribute
-
setAttribute
public void setAttribute(XmlObject target, String attributeNamespace, String attributeName, String attributeValue) Sets an attribute on the given xml element- Parameters:
target- the xml element on which to set the attributeattributeNamespace- namespace of the attributeattributeName- name of the attributeattributeValue- value of the attribute
-
parse
Parses the xml string into an XmlObject.- Parameters:
xml- the xml string- Returns:
- the XmlObject
- Throws:
IllegalArgumentException- if any problems are encountered parsing the string
-
addAsLastChild
Adds child as the last child element of target.- Parameters:
target- the xml element to which the child will be addedchild- the xml element that will be added- Returns:
- a reference to the child element in the new context
-
addAsFirstChild
Adds child as the first child element of target.- Parameters:
target- the xml element to which the child will be addedchild- the xml element that will be added- Returns:
- a reference to the child element in the new context
-
getFirstChild
Returns the first child element of the given xml.- Parameters:
xmlObject- the parent xml element- Returns:
- the first child element of the given XmlObject or null, if it has no child elements.
-
getChildren
Returns all the child elements of the given xml.- Parameters:
xmlObject- the parent xml element- Returns:
- a list of child elements
-