", "text": "<p>I have some problem getting all the HTML tags after <code>&lt;script&gt;</code>...<code>&lt;script/&gt;</code> using XPath.</p>\n\n<p>My HTML:</p>\n\n<pre class="prettyprint"><code>&lt;table dir="rtl"...&gt;\n &lt;tbody&gt;\n &lt;tr&gt;..&lt;/tr&gt;\n &lt;script src = get.aspx?type=js&amp;file=ajax&amp;rev=3 ....&gt;\n &lt;script language="JavaScript".....&gt;\n &lt;script&gt;...&lt;script&gt;\n &lt;tr&gt;..&lt;/tr&gt;\n &lt;tr&gt;..&lt;/tr&gt;\n &lt;tr&gt;..&lt;/tr&gt;\n &lt;tr&gt;..&lt;/tr&gt;\n &lt;tr&gt;..&lt;/tr&gt;\n</code></pre>\n\n<p>I want to get all tags after the script tag in XPath.</p>\n\n<p>This is the link to the web page: source</p>", "answerCount": 1, "upvoteCount": 932, "dateCreated": "2026-08-21 12:45:06", "dateModified": "2026-08-24 12:10:19", "author": { "type": "Person", "name": "adellam" }, "acceptedAnswer": { "@type": "Answer", "text": "<p>The html you posted has a <code>&lt;script&gt;...&lt;script&gt;</code><sup>1</sup> after <code>&lt;script language="JavaScript".....&gt;</code>, but the source does not have the extra <code>&lt;script&gt;</code> tag(s). </p>\n\n<p>For the source HTML, this XPath works:</p>\n\n<pre class="prettyprint"><code>//script[@language="JavaScript"]/following::tr\n</code></pre>\n\n<hr>\n\n<p><sup>1</sup> Did you mean <code>&lt;script&gt;...&lt;/script&gt;</code>?</p>", "upvoteCount": 98, "url": "https://exchangetuts.com/index.php/xpath-expression-to-select-all-tags-after-scriptscript-1769405102488810#answer-1787489106588732", "dateCreated": "2026-08-24 00:10:19", "dateModified": "2026-08-24 12:10:19", "author": { "type": "Person", "name": "unutbu" } } } }
Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xpath expression to select all tags after <script>.....</script>

Tags:

xpath

I have some problem getting all the HTML tags after <script>...<script/> using XPath.

My HTML:

<table dir="rtl"...>
    <tbody>
    <tr>..</tr>
    <script src = get.aspx?type=js&file=ajax&rev=3 ....>
    <script language="JavaScript".....>
    <script>...<script>
    <tr>..</tr>
    <tr>..</tr>
    <tr>..</tr>
    <tr>..</tr>
    <tr>..</tr>

I want to get all tags after the script tag in XPath.

This is the link to the web page: source

like image 932
adellam Avatar asked Aug 21 '26 12:08

adellam


1 Answers

The html you posted has a <script>...<script>1 after <script language="JavaScript".....>, but the source does not have the extra <script> tag(s).

For the source HTML, this XPath works:

//script[@language="JavaScript"]/following::tr

1 Did you mean <script>...</script>?

like image 98
unutbu Avatar answered Aug 24 '26 12:08

unutbu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!