I have tried grep, awk, sed and am starting to try xmlstarlet but I'm not finding much support with that.
I'm guessing the xmlstarlet is telling me that the XML is ill formed, but all I want to do is find tags that contain a specific hex color and print the text between the tags.
My file.xml looks like this:
<p style=" margin-left: 80.0px;">Do not print this.</p>
<p style=" margin-left: 80.0px;"><span style=" color: #595959;">Print this.</span></p>
I have tried
$ cat file.xml | grep -oP '(?<=\"<span style="color: #595959;">\").*?(?=\"</span>")'
grep produces no output
sed -n '/span style=" color: #595959/,/<\/span/p' file.xml
sed returns the entire line and continues to print every line afterwards in the xml file, but I only want the text between the tags.
awk -F "[><]" '/span style=" color: #595959;"’/{print $3} file.xml
awk command runs but does not terminate or print anything.
xmlstarlet produces:
Unescaped '<' not allowed in attributes values
which is referring to another line in the file, but I am guessing this violation is why xmlstarlet halts.