Skip to main content
Solved

XTMLFragmenter - get specific text

  • Dec 10, 2024 8:35 AM UTC
  • 5 replies
  • 124 views

marta.podsiad
Supporter
Forum|alt.badge.img+12

Hi,

 

I have a html content in _response_body. I am struggling to get only specific text from it. I would like to get only the text highlighted in red. 

<b>Layers: </b>
<ul>
<li>
<a href="/arcgis/rest/services/Imagery_Wayback_Ardstaw/MapServer/0">2014/02/20</a> (0)
</li>
<li>
<a href="/arcgis/rest/services/Imagery_Wayback_Ardstaw/MapServer/1">2016/12/07</a> (1)
 

How can I do it? I assume I should use XTMLFragmenter but I am struggling to get the result I want

Best answer by geomancer

To expand on ​@ebygomm's solution:

The values you want are in an <a> tag that is inside a <li> tag.

When you enter li a[href] under CSS Selector you will get only those values.

 

View original
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

ebygomm
Evangelist
Forum|alt.badge.img+54
  • Evangelist
  • Dec 10, 2024 10:37 AM UTC

If you want the link text this should work

You will then need to explode the created list


marta.podsiad
Supporter
Forum|alt.badge.img+12
  • Author
  • Supporter
  • Dec 10, 2024 12:18 PM UTC

it works perfect for the sting above, thanks! How can I change it if there are more items that begins with a href and still select only the text in red

 

<a href="/arcgis/rest/services/Imagery_Wayback_Ardstaw/MapServer/legend?dynamicLayers=%5B%5D&">Dynamic Legend</a><br/><br/>
<a href="/arcgis/rest/services/Imagery_Wayback_Ardstaw/MapServer/layers?dynamicLayers=%5B%5D&">Dynamic All Layers</a><br/><br/>
<b>Layers: </b>
<ul>
<li>
<a href="/arcgis/rest/services/Imagery_Wayback_Ardstaw/MapServer/0">2014/02/20</a> (0)
</li>
<li>
<a href="/arcgis/rest/services/Imagery_Wayback_Ardstaw/MapServer/1">2016/12/07</a> (1)


geomancer
Evangelist
Forum|alt.badge.img+69
  • Evangelist
  • Best Answer
  • Dec 10, 2024 1:43 PM UTC

To expand on ​@ebygomm's solution:

The values you want are in an <a> tag that is inside a <li> tag.

When you enter li a[href] under CSS Selector you will get only those values.

 


marta.podsiad
Supporter
Forum|alt.badge.img+12
  • Author
  • Supporter
  • Dec 11, 2024 10:43 AM UTC

How would it look like if I would like to select only the highlighted text?

<b>Display Field:</b> objectid<br/><br/>
<b>Type: </b> Feature Layer<br/><br/>
<b>Geometry Type:</b> esriGeometryPoint<br/><br/>
<b>Description: </b> <br/><br/>
<b>Service Item Id: </b> 4c0f943fb60a4a369104f33d1ad2af4f<br/><br/>


hkingsbury
Celebrity
Forum|alt.badge.img+73
  • Celebrity
  • Dec 11, 2024 7:35 PM UTC

How would it look like if I would like to select only the highlighted text?

<b>Display Field:</b> objectid<br/><br/>
<b>Type: </b> Feature Layer<br/><br/>
<b>Geometry Type:</b> esriGeometryPoint<br/><br/>
<b>Description: </b> <br/><br/>
<b>Service Item Id: </b> 4c0f943fb60a4a369104f33d1ad2af4f<br/><br/>

With that one, i’d look to use a string searcher and regex.
 

<b>Service Item Id: <\/b> (.+)<br\/><br\/>


You’ll need to enable subexpression matches