Class XMLParser
- Author:
- rsoika
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
findAttribute
(String content, String name) This method parses a xml tag for a single named attribute.findAttributes
(String content) This method parses a xml tag for attributes.findNoEmptyTags
(String content, String tag) This method finds no-empty tags by name inside a string and returns a list with all tags including the tag itself.findNoEmptyXMLTags
(String content, String tag) This method finds no-empty tags by name inside a string and returns the embedded XML content.This method find specific tags inside a string and returns a list with all tags.static String
findTagValue
(String content, String tag) This method returns the tag value of a single tag.static String
findTagValueOld
(String content, String tag) Deprecated.findTagValues
(String content, String tag) This method returns all tag values within a string with multiple xml tags.static boolean
isXMLContent
(String content) Test if a given String is XML Contentstatic ItemCollection
parseItemStructure
(String xmlContent) This method parses the xml content of a item element and returns a new ItemCollection containing all item values.static ItemCollection
This method parses the xml content of a XML tag and returns a new ItemCollection containing all embedded tags.static List<ItemCollection>
parseTagList
(String content, String tag) This method parses the xml content and returns a list of ItemCollection elements for each tag with the given tag name
-
Constructor Details
-
XMLParser
public XMLParser()
-
-
Method Details
-
findAttributes
This method parses a xml tag for attributes. The method returns a Map with all attributes found in the content string e.g.- returns Map: {field=a, number=1}
- Parameters:
content
-- Returns:
-
findAttribute
This method parses a xml tag for a single named attribute. The method returns the value of the attribute found in the content string e.g.- returns "abc"
- Parameters:
content
-- Returns:
-
findTags
This method find specific tags inside a string and returns a list with all tags.e.g. an empty tag:
<date field="abc" />
or a tag with content:
<date field="abc">def</date>
Note: In case of complex XML with not empty tags use the method 'findNoEmptyTags'
- Parameters:
content
- - XML datatag
- - XML tag- Returns:
-
findNoEmptyTags
This method finds no-empty tags by name inside a string and returns a list with all tags including the tag itself.e.g.:
<date field="abc">def</date>
Note: To find also empty tags use 'findTags'
- Parameters:
content
- - XML datatag
- - XML tag- Returns:
-
findNoEmptyXMLTags
This method finds no-empty tags by name inside a string and returns the embedded XML content. The method returns a list of xml tags including the tag itself.e.g.:
<date field="abc">def</date>
Note: To find also empty tags use 'findTags'
- Parameters:
content
- - XML datatag
- - XML tag- Returns:
-
isXMLContent
Test if a given String is XML Content- Parameters:
content
-- Returns:
-
findTagValues
This method returns all tag values within a string with multiple xml tags. E.g.<date>2016-12-31</date>...<date>2016-11-30</date>
returns
2016-12-31|2016-12-31
- Parameters:
content
- - XML datatag
- - XML tag- Returns:
-
findTagValue
This method returns the tag value of a single tag. The method returns the first match! Use findTagValues to parse all tag values in a string with multiple tags.E.g.
<date>2016-12-31</date>...<date>2016-11-30</date>
returns
2016-12-31
- Parameters:
content
- - XML datatag
- - XML tag- Returns:
- See Also:
-
findTagValueOld
Deprecated. -
parseItemStructure
This method parses the xml content of a item element and returns a new ItemCollection containing all item values. Each tag is evaluated as the item name. MultiValues are currently not supported. Example:<item> <modelversion>1.0.0</modelversion> <task>1000</task> <event>10</event> </item>
- Parameters:
evalItemCollection
-- Throws:
PluginException
-
parseTag
This method parses the xml content of a XML tag and returns a new ItemCollection containing all embedded tags. Each tag is evaluated as the item name. The tag value is returned as a item value.MultiValues are currently not supported.
Example:
The tag 'code' of:
<code> <modelversion>1.0.0</modelversion> <task>1000</task> <event>10</event> </code>
Returns an ItemCollection with 3 items (modelversion, task and event)
- Parameters:
evalItemCollection
-- Throws:
PluginException
-
parseTagList
This method parses the xml content and returns a list of ItemCollection elements for each tag with the given tag nameExample:
The tag 'code' of:
<code> <modelversion>1.0.0</modelversion> <task>1000</task> <event>10</event> </code> <code> <modelversion>2.0.0</modelversion> <task>2000</task> <event>20</event> </code>
Returns a List with two ItemCollections each with 3 items (modelversion, task and event)
- Parameters:
evalItemCollection
-- Throws:
PluginException
-