2
私は、BaseXを使ってHTMLページを解析しようとしています。 コードのこの部分から:htmlリンクでテキストを抽出する方法は?
<td colspan="2" rowspan="1" class="light comment2 last2">
<img class="textalign10" src="templates/comment10.png"
alt="*" width="10" height="10" border="0"/>
<a shape="rect" href="mypage.php?userid=26682">user</a>
: the text I'd like to keep [<a shape="rect"
href="http://alink" rel="nofollow">Link</a>] . with that part too.
</td>
私はa
HTMLリンク、とメッセージを抽出し、初めに最初の:
文字を削除する必要があります。
declare
function gkm:node_message_from_comment($comment as item()*) {
if ($comment) then
copy $c := $comment
modify (
delete node $c/img[1],
delete node $c/a[1],
delete node $c/@*,
rename node $c as 'message'
)
return $c
else()
};
が、私はテキストを抽出することができ、この機能を使用して
<message>
the text I'd like to keep [<a shape="rect" href="http://alink" rel="nofollow">Link</a>] . with that part too.
</message>
、私は初めから:
の削除に失敗しました:
私はこの正確なテキストを取得したいと思います。 すなわち:XQueryの更新と変換ステートメントを使用して
<message>
: the text I'd like to keep [<a shape="rect" href="http://alink" rel="nofollow">Link</a>] . with that part too.
</message>
は完璧に動作し、感謝を:) – KumZ