Extract specific text from Screenshot XML

243 views
Skip to first unread message

Jamie Jackson

unread,
Aug 12, 2021, 10:05:48 AM8/12/21
to Automate
Hi all...

Hoping somebody could help me extract text from an XML (screenshot) and save the output.
I'm currently trying to find anything that has an "£"
or from the 'android:text' field.

Example line from the XML:
<android.widget.TextView android:enabled="true" android:id="@com.utilita.customerapp:id/balance" android:layout_height="164px" android:layout_width="649px" android:layout_x="313px" android:layout_y="585px" android:text="£35.81"/>


Jamie Jackson

unread,
Aug 12, 2021, 10:29:49 AM8/12/21
to Automate
I'm also struggling to use the substr 

I'm using the below but only returns the first 5 lines of the XML
substr(xml,"£",5)

Message has been deleted

thec...@gmail.com

unread,
Aug 12, 2021, 11:36:46 AM8/12/21
to Automate
substr argument 2 has to be a number, so use indexOf() to find the index/number of the £ character
eg.
`substr(xml, indexOf(xml, "£"), 5)`

Henrik "The Developer" Lindqvist

unread,
Aug 12, 2021, 3:19:56 PM8/12/21
to Automate
Try using the Inspect layout block with XPath expression:
.//android.widget.TextView[@android:id='@com.utilita.customerapp:id/balance' and starts-with(@android:text, '£')]/@android:text

Jamie Jackson

unread,
Aug 12, 2021, 4:14:04 PM8/12/21
to Automate
Thanks, both of these work but only return one value. 
I've tried an "apply to each" but still can't get that part working.

Thanks again!

Henrik "The Developer" Lindqvist

unread,
Aug 12, 2021, 5:53:32 PM8/12/21
to Automate
Try with:
//android.widget.TextView[@android:id='@com.utilita.customerapp:id/balance' and starts-with(@android:text, '£')]/@android:text

And ensure to set Result type to Node set.
Message has been deleted

Henrik "The Developer" Lindqvist

unread,
Sep 18, 2022, 5:30:31 AM9/18/22
to Automate
Since they no longer include any @android:id attribute, more of the XML has to be match for context. Maybe some of that TextView parent has an @android:id?

On Saturday, September 17, 2022 at 9:28:47 PM UTC+2 JJ wrote:
Turns out the App just updated.

Is it possible to update the above to extract from this?

<android.widget.TextView android:enabled="true" android:layout_height="124px" android:layout_width="305px" android:layout_x="919px" android:layout_y="1156px" android:text="£59.48"/>
Message has been deleted
Message has been deleted

Henrik "The Developer" Lindqvist

unread,
Sep 19, 2022, 10:35:47 AM9/19/22
to Automate
Reply all
Reply to author
Forward
0 new messages