Package org.imixs.workflow.util
Class XMLParser
java.lang.Object
org.imixs.workflow.util.XMLParser
XMLParser provides helper methods to parse xml strings
- 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 find not-empty tags inside a string and returns a list with all tags.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 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.
-
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 find not-empty tags inside a string and returns a list with all tags.e.g.:
<date field="abc">def</date>
Note: To fine also empty tags use 'findTags'
- Parameters:
content
- - XML datatag
- - XML tag- 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
-