<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>factal</author_name>
  <author_url>https://blog.hatena.ne.jp/factal/</author_url>
  <blog_title>うおっ</blog_title>
  <blog_url>https://factal.hatenadiary.org/</blog_url>
  <categories>
    <anon>プログラミング</anon>
    <anon>lxml</anon>
  </categories>
  <description>以下のような XML があったとする。 &lt;document&gt; &lt;deleteme&gt;この要素をタグごと消したい。&lt;wac/&gt; あああああ &lt;/deleteme&gt; &lt;/document&gt; ここで、 要素のテキストを消したい。 &gt;&gt;&gt; xml = open('sample.xml', 'rb').read() &gt;&gt;&gt; root = lxml.html.fromstring(xml) &gt;&gt;&gt; elements = root.xpath('//deleteme') &gt;&gt;&gt; for e in elements: ... del e ... &gt;&gt;&gt; print root.text_content() この要…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Ffactal.hatenadiary.org%2Fentry%2F20120706%2F1341565778&quot; title=&quot;子要素をもつ XML のテキストを lxml で消したい - うおっ&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2012-07-06 18:09:38</published>
  <title>子要素をもつ XML のテキストを lxml で消したい</title>
  <type>rich</type>
  <url>https://factal.hatenadiary.org/entry/20120706/1341565778</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
