I can't figure out two expressions in xpath. Can someone help ?

Here they are

substring-after(substring-before(//ul[@id='biblio']/li[3], ']', '['))

//h2[normalize-space(string())='name']/preceding::h1[1]

in the first xquery query an error is included
substring-before and substring-after only possess
maximum of 2 arguments
then from the query

substring-after (substring-before (/ / ul [@ id = 'biblio'] / li [3], ']'), '[')

as an example

<? xml version = "1.0"?>
<root>
<ul id="biblio">
<li>
</ li>
<li>
</ li>
<li> [abcdef] </ li>
</ ul>
</ root>

result

abcdef

in the second query the predecessor of h1 h2 tag is used to find content name blank will be deleted

as for example

<? xml version = "1.0"?>
<root>
<h1> aaaaaaa </ h1>
<h1> bbbbbbb </ h1>
<h2> name </ h2>
</ root>





/ / h2 [normalize-space (string ()) = 'name'] / preceding :: h1 [1]

result
bbbbbbb

/ / h2 [normalize-space (string ()) = 'name'] / preceding :: h1 [2]

result
aaaaaaa

/ / h2 [normalize-space (string ()) = 'name'] / preceding :: h1

result
aaaaaaa
bbbbbbb

hope this will help you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.