- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-04-22 06:24 PM
I wanted to parse some data from XML file and thought to use the Utility - XML provided by Blue Prism.
Soon I came to the point where it seems the VBO cannot help me anymore.
I used following file:
And want to read the value of this line:
The action Get Attribute returns only:
There seem to be three ways on presenting key/value pairs in XML:
https://stackoverflow.com/questions/1543388/xml-dom-storing-key-value-pairs
I looked at DX if there is a newer version available but the VBO handles key/values the same way.
(btw the version number in DX is 1.0.0 but the file is named BPA+Object+-+Utility+-+XML_v2.0.xml and was updated two days ago.
Also the link to the readme.md file does not work anymore)
Is this a community topic or should I create support ticket?
------------------------------
Walter Koller
Solution Manager
Erste Group IT International GmbH
Europe/Vienna
------------------------------
Answered! Go to Answer.
Helpful Answers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-04-22 09:31 PM
I just took a look at this and it seems to work fine. Here's how I get the key name and key value using the Get Attributes action:
- I started by reading the contents of the config file.
- Then a pulled a collection of the <add /> elements.
- Next, I iterate over the rows of the collection pulling the values for the two attributes named key and value.
BTW - We've fixed the documentation and version issues too.
Cheers,
------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-04-22 08:40 PM
Go ahead and open a ticket on this. That way we'll have some tracking on it.
Cheers,
------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-04-22 09:31 PM
I just took a look at this and it seems to work fine. Here's how I get the key name and key value using the Get Attributes action:
- I started by reading the contents of the config file.
- Then a pulled a collection of the <add /> elements.
- Next, I iterate over the rows of the collection pulling the values for the two attributes named key and value.
BTW - We've fixed the documentation and version issues too.
Cheers,
------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-04-22 09:22 AM
Thanks a lot for your quick and working solution.
There would be also a decision necessary to manually verify if the KEY is the one I am looking for.
This should work, although it is a little more complex than using the Get Attribute action once and getting exactly the value what I am looking for.
When looking at the Utility - XML code for Get Attribute:
//Attribute holds the value provided to the action: v3k1
i += Attribute.length + 2 //i is set to the character after: v3k1">
value = XML.substring(i) //value is set to: v3val1</key>
value = value.substring(0, value.indexof("""")) //right side of value is truncated to the first "
//if value = "v3val1"</key> then the result is " (I guess single " will be ignored in BP the result is therefore empty)
//if value = v3val1</key> then the result is v3val1</key> (ie until EOL) since no " is found
or did I miss something?
------------------------------
Walter Koller
Solution Manager
Erste Group IT International GmbH
Europe/Vienna
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
28-04-22 11:55 AM
I think there's a little misunderstanding here. In terms of the XML specification, the two items key and value are nothing more than attributes on the add element. They could just as easily be named john and doe. If you know the name of the attribute and you use the Get Attribute action you will get the exact value of that attribute.
In your example, <key name="v3k1">v3val1</key>, the parts of the XML are as follows:
- <key ...>...</key> is an XML element
- name="v3val1" is an attribute of the element <key>...</key>
- v3val is the value of the element <key>...</key>
- v3k1 is the value of the attribute name
Cheers,
------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
29-04-22 08:17 AM
Hi Eric, thanks a lot for taking your time for explaining what the knot in my thinking is.
It seems I found a very bad and confusing example of XML for testing the VBO.
For me KEY and its VALUE is basically one entity, thus I was assuming the meaning of the structure instead of reading the actual syntax. Thanks for pointing this out 🙂
------------------------------
Walter Koller
Solution Manager
Erste Group IT International GmbH
Europe/Vienna
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-10-22 03:25 PM
I tried to implement your solution for the below XML format. But, I am not able to get the value which is corresponding to "id" and "cycle-id". Could you please help me with the same ?
<Field Name ="id" ><Value>12345<Value></Field><Field Name ="cycle-id" ><Value>67891<Value></Field>
Thanks in Advance!Kind Regards,
------------------------------
Kiran Singh
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-10-22 04:13 PM
First issue is that your XML is not valid. The Value elements are not properly terminated. They should be defined as <Value>...</Value>. Your missing the forward slash on the closing tag.
Cheers,
------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-10-22 05:59 PM
Thanks for highlighting the syntax error. This was a typing error on my side in the chat. Could you please suggest a solution to fetch value against "id and "cycle -id"?
XML after correction :
<Field Name ="id" ><Value>12345</Value></Field><Field Name ="cycle-id" ><Value>67891</Value></Field>
------------------------------
Kiran Singh
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
18-10-22 06:53 PM
Is the XML that you're working with part of a larger document? The snippet that you've shown in your example probably isn't being processed because there's no root/container element. You just have two Field elements at the same level. If you wrap your example XML in a container element then you can call Get Elements and it will return a Collection with two records (each of the Field elements).
Here's an example of what the XML should look like:
<Fields>
<Field Name ="id" >
<Value>12345</Value>
</Field>
<Field Name ="cycle-id" >
<Value>67891</Value>
</Field>
</Fields>
And here's what my Get Elements call looks like:
After that, you can loop the Collection to pull out the value of the Name attribute using the Get Attribute action:
And then you can use XPath to pull out the Value element contained within the Field element:
This is what the output Collection looks like for that:
Finally, you have an internal loop (loop within the outer loop) to loop over the Value Collection. Put it all together and it looks something like this:
Cheers,
------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------
