Package com.pingidentity.sdk.xml
Class XmlHelper
- java.lang.Object
-
- com.pingidentity.sdk.xml.XmlHelper
-
public class XmlHelper extends Object
A utility class to help with some common/basic XML manipulation tasks.- Since:
- 8.0
-
-
Constructor Summary
Constructors Constructor Description XmlHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description XmlObjectaddAsFirstChild(XmlObject target, XmlObject child)Adds child as the first child element of target.XmlObjectaddAsLastChild(XmlObject target, XmlObject child)Adds child as the last child element of target.XmlObjectaddToSaml2Extensions(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.List<XmlObject>getChildren(XmlObject xmlObject)Returns all the child elements of the given xml.XmlObjectgetFirstChild(XmlObject xmlObject)Returns the first child element of the given xml.XmlObjectparse(String 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
-
-
-
Method Detail
-
addToSaml2Extensions
public XmlObject 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.- 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
public void setAttribute(XmlObject target, String attributeName, String attributeValue)
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
public XmlObject parse(String xml)
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
public XmlObject addAsLastChild(XmlObject target, XmlObject child)
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
public XmlObject addAsFirstChild(XmlObject target, XmlObject child)
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
public XmlObject getFirstChild(XmlObject xmlObject)
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.
-
-