[Tutor] xpath - html entities issue -- &

Random832 random832 at fastmail.com
Tue Oct 4 10:41:21 EDT 2016


On Tue, Oct 4, 2016, at 10:02, bruce wrote:
> import libxml2dom
> 
> q1=libxml2dom
> 
> s2= q1.parseString(a.toString().strip(), html=1)
> tt=s2.xpath(tpath)
> 
> tt=tt[0].toString().strip()
> print "tit "+tt
> 
> -------------------------------------
> 
> 
> the content of a.toString() (shortened)

What type is a? What is tpath? Please post a complete self-contained
example that actually runs and shows your problem.

> I'm wondering if there's a process that can be used within the
> toString() or do you really have to wrap each xpath/toString with
> a unescape() kind of process to convert htmlentities to the
> requisite chars.

Why are you using toString? I can't tell if you want a text string or
HTML - if you want HTML then you should be fine with the & - if you
want text, then shouldn't the <tags> be a bigger problem than the
entity?


More information about the Tutor mailing list