Why no response to Re^3: Extracting specific childnodes (xpath whitespace)?
If you're game, I'm game ; I'll play if you'll play;
Using the previous answer
$ xmllint.exe --shell madbee.xml
/ >
/ > cat //H4[ contains(.,'Include')] /..//LI
-------
<LI>
<LI_Label>1.</LI_Label>
<LI_Title>Critera 1</LI_Title>
</LI>
-------
<LI>
<LI_Label>2.</LI_Label>
<LI_Title>Critera 2</LI_Title>
</LI>
-------
<LI>
<LI_Label>3.</LI_Label>
<LI_Title>Critera 3</LI_Title>
</LI>
-------
<LI>
<LI_Label>4.</LI_Label>
<LI_Title>Critera 3</LI_Title>
</LI>
/ >
/ >
/ > cat //H4[ contains(.,'Include')] /..//LI_Title
-------
<LI_Title>Critera 1</LI_Title>
-------
<LI_Title>Critera 2</LI_Title>
-------
<LI_Title>Critera 3</LI_Title>
-------
<LI_Title>Critera 3</LI_Title>
/ >
/ > bye
$
Debugging /diagnosing and fixing this latest typo-ed answer
$ xmllint.exe --shell madbee.xml
/ >
/ > cat //Article/Main/Sect/*[ ( name()="H3" or name()="H4" ) and cont
+ains(.,"Include" ) ]//LI_Title
/ >
/ > whereis //Article/Main/Sect/*[ ( name()="H3" or name()="H4" ) and
+contains(.,"Include" ) ]//LI_Title
/ >
/ > cat //Article/Main/Sect/*[ ( name()="H3" or name()="H4" ) and cont
+ains(.,"Include" ) ]
-------
<H4>Include</H4>
/ >
/ > whereis //Article/Main/Sect/*[ ( name()="H3" or name()="H4" ) and
+contains(.,"Include" ) ]
/Article/Main/Sect/H4
/ >
/ > whereis //LI_Title
/Article/Main/Sect/L/LI[1]/LI_Title
/Article/Main/Sect/L/LI[2]/LI_Title
/Article/Main/Sect/L/LI[3]/LI_Title
/Article/Main/Sect/L/LI[4]/LI_Title
/ >
/ >
/ > cat //Article/Main/Sect/*[ ( name()="H3" or name()="H4" ) and cont
+ains(.,"Include" ) ]/../LI_Title
/ >
/ > cat //Article/Main/Sect/*[ ( name()="H3" or name()="H4" ) and cont
+ains(.,"Include" ) ]/..//LI_Title
-------
<LI_Title>Critera 1</LI_Title>
-------
<LI_Title>Critera 2</LI_Title>
-------
<LI_Title>Critera 3</LI_Title>
-------
<LI_Title>Critera 3</LI_Title>
/ >
/ >
/ >
/ > grep Include
/Article/Main/Sect/H4 : tan 7 Include
/ >
/ >
/ > grep Critera
/Article/Main/Sect/L/LI[1]/LI_Title : t-- 9 Critera 1
/Article/Main/Sect/L/LI[2]/LI_Title : t-- 9 Critera 2
/Article/Main/Sect/L/LI[3]/LI_Title : t-- 9 Critera 3
/Article/Main/Sect/L/LI[4]/LI_Title : t-- 9 Critera 3
/ >
/ >
/ > bye
$
Using the power of parens in xpath / parentheses in xpath
$ xmllint.exe --shell madbee.xml
/ > cat //Article/Main/Sect/H4
-------
<H4>Include</H4>
/ >
/ >
/ > cat ( //Article/Main/Sect/H3 | //Article/Main/Sect/H4 )
-------
<H4>Include</H4>
/ >
/ >
/ > cat ( //Article/Main/Sect/H3 | //Article/Main/Sect/H4 )[ contains(
+.,'Include' ) ]
-------
<H4>Include</H4>
/ >
/ >
/ > cat ( //Article/Main/Sect/H3 | //Article/Main/Sect/H4 )[ contains(
+.,'Include' ) ]/..//LI_Title
-------
<LI_Title>Critera 1</LI_Title>
-------
<LI_Title>Critera 2</LI_Title>
-------
<LI_Title>Critera 3</LI_Title>
-------
<LI_Title>Critera 3</LI_Title>
/ >
/ >
/ >
/ > cat ( //Article/Main/Sect/H3 | //Article/Main/Sect/H4 )[ contains(
+.,'Junk' ) ]/..//LI_Title
/ >
/ >
/ >
/ > bye
$
You can even give node sets to xpath string functions like contains() so you don't have to go to parent(..) then find descendents(//)
$ xmllint.exe --shell madbee.xml
/ >
/ >
/ > whereis //Article/Main/Sect
/Article/Main/Sect
/ >
/ >
/ > whereis //Article/Main/Sect[ ( H3 | H4 ) ]
/Article/Main/Sect
/ >
/ >
/ > whereis //Article/Main/Sect[ contains( ( H3 | H4 ), 'Junk' ) ]
/ >
/ > whereis //Article/Main/Sect[ contains( ( H3 | H4 ), 'Include' ) ]
/Article/Main/Sect
/ >
/ > whereis //Article/Main/Sect[ contains( ( H3 | H4 ), 'Include' ) ]
+//LI_Title
/Article/Main/Sect/L/LI[1]/LI_Title
/Article/Main/Sect/L/LI[2]/LI_Title
/Article/Main/Sect/L/LI[3]/LI_Title
/Article/Main/Sect/L/LI[4]/LI_Title
/ >
/ >
/ > bye
$