删除特定标题后的所有<p>或</p> <ol>或所有HTML元素,直到下一个标题

时间:2017-07-14 08:20:54

标签: xpath

我希望在包含满足特定条件的标题之后删除文档节点中的所有html标记,直到新的标题元素标记。

例如:我想删除带有id =“notes”的标题和所有后续的html标签,直到出现新的标题标签。此模式可以位于html页面中的任何位置。 输入:

<h2><span class="mw-headline" id="Notes">Notes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a title="Edit section: Notes" href="/w/index.php?title=Microsoft_HoloLens&amp;action=edit&amp;section=9">edit</a><span class="mw-editsection-bracket">]</span></span></h2> 
<div class="reflist" style="list-style-type: decimal;">
<div class="mw-references-wrap">
<ol class="references">
<li id="cite_note-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-19"><span class="cite-accessibility-label">Jump up </span>^</a></b></span> <span class="reference-text">See also: <a title="3D audio effect" href="/wiki/3D_audio_effect">3D audio effect</a>, <a title="Virtual surround" href="/wiki/Virtual_surround">virtual surround</a>, <a title="Psychoacoustics" href="/wiki/Psychoacoustics">psychoacoustics</a></span></li>
</ol>
</div>
</div>
<p>3D applications, or "holographic" applications, use Windows Holographic APIs. Microsoft recommends <a title="Unity (game engine)" href="/wiki/Unity_(game_engine)">Unity</a> engine and <a title="Vuforia Augmented Reality SDK" href="/wiki/Vuforia_Augmented_Reality_SDK">Vuforia</a> to create 3D apps for HoloLens, but it's also possible for a developer to build their own engine using <a title="DirectX" href="/wiki/DirectX">DirectX</a> and <a title="Windows API" href="/wiki/Windows_API">Windows APIs</a>.<sup class="reference" id="cite_ref-62"><a href="#cite_note-62">[61]</a></sup></p>
<h2><span class="mw-headline" id="References">References</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a title="Edit section: References" href="/w/index.php?title=Microsoft_HoloLens&amp;action=edit&amp;section=10">edit</a><span class="mw-editsection-bracket">]</span></span></h2>

输出应该是这样的:

<h2><span class="mw-headline" id="References">References</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a title="Edit section: References" href="/w/index.php?title=Microsoft_HoloLens&amp;action=edit&amp;section=10">edit</a><span class="mw-editsection-bracket">]</span></span></h2>

0 个答案:

没有答案