Skip to main content
Solved

XTMLFragmenter - get specific text

  • December 10, 2024
  • 5 replies
  • 63 views

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

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
Did this help you find an answer to your question?

5 replies

ebygomm
Influencer
Forum|alt.badge.img+40
  • Influencer
  • December 10, 2024

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+9
  • Author
  • Supporter
  • December 10, 2024

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+53
  • Evangelist
  • Best Answer
  • December 10, 2024

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+9
  • Author
  • Supporter
  • December 11, 2024

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+58
  • Celebrity
  • December 11, 2024
marta.podsiad wrote:

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
 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings