0

Ruby で doc.xpath を使用して XML ファイルから body ノード/タグのみを抽出したい

XML ファイルから抽出するノード:

<wcm:element name="Body">&lt;p&gt;A new study suggests that &lt;a href="ssNODELINK/SmokingAndCancer"&gt;tobacco&lt;/a&gt; companies may be using online video portals, such as YouTube, to get around advertising restrictions and market their products to young people.&lt;/p&gt;
</wcm:element>

私は次のことを試しました:

page_content = doc.xpath("/wcm:root/wcm:element").inner_text

しかし、これはすべてのノードをすべて抽出します

それから私はこれを試しました:

page_content = doc.xpath("/wcm:root/wcm:element/Body")

しかし、うまくいきません。

Ruby で doc.xpath を使用して XML ファイルの本文セクションを正確に抽出する方法を提案する人はいますか?

4

1 に答える 1