• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Extract content from HTML string associated with a particular element.

I need a function to extract the value in this string that is associated with the Display Text element.   I want to use this code in an Access query.
In this example the function returns "Joe Green"


<PickerEntities><PickerEntity><Description>Match found</Description><DisplayText>Joe Green</DisplayText><IsResolved>true</IsResolved><Key>Green, Joe</Key><EntityData><EntityDataItem><Key>Last Name</Key><Value>Green</Value></EntityDataItem><Entity
0
StevenPMoffat
Asked:
StevenPMoffat
  • 3
  • 2
1 Solution
 
Robert SchuttSoftware EngineerCommented:
something like this?
 Mid([xml],InStr([xml],'<DisplayText>')+13,InStr([xml],'</DisplayText>')-13-InStr([xml],'<DisplayText>'))

Open in new window

0
 
Robert SchuttSoftware EngineerCommented:
Here's how it looks.
captureHope you were looking for something like that.
0
 
StevenPMoffatAuthor Commented:
This almost works.   It does in the case that I have presented to you, but in a similar case it doesn't work.    What does the 13 represent?  

Here is the other example that doesn't work.
<PickerEntities><PickerEntity><Description>Match found</Description><DisplayText>Paul Juneau</DisplayText><IsResolved>true</IsResolved><Key>Juneau, Paul</Key><EntityData><EntityDataItem><Key>Last Name</Key><Value>Juneau</Value></EntityDataItem><EntityData
0
 
StevenPMoffatAuthor Commented:
Ignore my previous concern.  My mistake.
0
 
Robert SchuttSoftware EngineerCommented:
Ignore the whole post? Just in case you still wanted to know the first part: 13 is the length of the first search text "<DisplayText>".

EDIT: you may need a check if it is ever possible that the search text doesn't occur in the string.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now