目标:仅使用且仅使用锚 ID (msg123456) 作为起点获取锚链接 (some_path) 和锚值 (用户名)的值。
HTML:
<!-- a lot of HTML code before this -->
<a id="msg123456"></a><a id="new"></a>
<div class="windowbg">
<span class="topslice"><span></span></span>
<div class="post_wrapper">
<div class="poster">
<h4><a href="some_path" title="some_user">User Name</a></h4>
</div>
</div>
</div>
<!-- a lot of HTML code after this -->
问题:我知道如何将 XPATH 用于简单任务,但在这种情况下,我不确定从哪里开始。