XML
Overview¶
AMI supports building and/or modification of XML files. This section will discuss the various ways to work with XML files in AMI.
Contents:
- AMI XML Classes
- Example Workflows
AMI XML Classes¶
XmlParser¶
Method | Return Type | Description |
---|---|---|
constructor |
XmlParser | Creates a XML parser. |
getClassName() |
String | Returns the string name of this object's class type. |
parseDocument(String xml) |
XmlElement | Parses an XML string and returns an XmlElement object. |
toJson() |
String | Returns a JSON representation of this object. |
Constructor
Creates an XML parser.
getClassName()
Creates a xml parser.
parseDocument(string xml)
Parses an xml string and returns an XmlElement object.
toJson()
Returns a json representation of this object.
XmlText¶
Method | Return Type | Description |
---|---|---|
constructor(string string) |
XmlParser | Creates an XmlText node based on the given string. |
getClassName() |
String | Returns the string name of this object's class type. |
toJson() |
String | Returns a JSON representation of this object. |
toLegibleString() |
String | Returns the XmlText node as a legible string. |
toString() |
String | Returns the XmlText node as a string. |
Constructor
Creates an XmlText node based on the given string.
getClassName()
Creates a xml parser.
toJson()
Returns a json representation of this object.
toLegibleString()
Returns the XmlText node as a legible string.
toString()
Returns the XmlText node as a string.
XmlElement¶
Method | Return Type | Description |
---|---|---|
constructor(String xmlString) |
XmlElement | Creates an XML Element from an XML String |
addAttribute(String key, String value) |
XmlElement | Add an attribute to the XmlElement corresponding to the key-value pair. |
addAttribute(String key, Long value) |
XmlElement | Add an attribute to the XmlElement corresponding to the key-value pair. |
addAttribute(String key, Double value) |
XmlElement | Add an attribute to the XmlElement corresponding to the key-value pair. |
addNode(XmlText xmlText) |
XmlElement | Add an existing XmlText node to the XmlElement. |
getAttribute(String name) |
String | Gets the attribute specified by a name. |
getAttributes() |
Map | Returns any attributes of the current element. |
getChildren() |
List | Returns a list of the XmlElement's children. |
getClassName() |
String | Returns the string name of this object's class type. |
getElements() |
List | Returns any elements within the current element. |
getElements(String name) |
String | Returns any elements within the current element based on the name specified. |
getFirstElement(String name) |
XmlElement | Returns the first element with the specified name. |
getInnerAsString() |
String | Returns inner value of element as string. |
getName() |
String | Returns tag name of current element. |
hasAttribute(String key) |
String | Returns tag name of current element. |
removeAttribute(String name) |
XmlElement | Remove an attribute based on the attribute name entered. |
toJson() |
String | Returns a JSON representation of this object. |
toLegibleString() |
String | Returns the XmlElement as a legible string. |
toString() |
String | Returns the XmlElement as a string. |
Constructor(string xmlString)
Creates an XML Element from an XML String.
addAttribute(String key, String value)
Add an attribute to the XmlElement corresponding to the key-value pair.
addAttribute(String key, Long value)
Add an attribute to the XmlElement corresponding to the key-value pair.
addAttribute(String key, Double value)
Add an attribute to the XmlElement corresponding to the key-value pair.
addNode(XmlText xmltext)
Add an existing XmlText node to the XmlElement.
getAttribute(String name)
Gets the attribute specified by a name.
getAttributes()
Returns any attributes of the current element.
getChildren()
Returns a list of the XmlElement's children.
getClassName()
Returns the string name of this object's class type.
getElements()
Returns any elements within the current element.
getElements(String name)
Returns any elements within the current element based on the name specified.
getFirstElement(String name)
Returns the first element with the specified name.
getInnerAsString()
Returns inner value of element as string.
getName()
Returns tag name of current element.
hasAttribute(String key)
Check if the XmlElement contains an attribute based on the entered key.
removeAttribute(String name)
Remove an attribute based on the attribute name entered.
toJson()
Returns a JSON representation of this object..
toLegibleString()
Returns the XmlElement as a legible string.
toString()
Returns the XmlElement as a legible string.
Sample Use Case¶
Displaying XML in HTML panel¶
Steps to display the parsed XML inside a HTML textarea field.¶
The sample code below will display the parsed XML inside a HTML text area.