How to remove text not in tag using lxml?



Now i got xml like following:



<div>
<p>the first paragraph</p>
<p>the sencond paragraph</p>
something others...
</div>


And i want remove these something others... from object content.


I know it can be got by using content.xpath('.//text()[not(ancestor::p)]'), but it seems be no good method to remove these text directly from object.


No comments:

Post a Comment