python - How do you extract an embedded attribute value from a previous attribute value in an XPath query? -


i'm trying "select" link onclick attribute in following portion of html

<span onclick="javascript:document.quickfindform.action='/blah_blah'"   class="speciallinktype"><img src="blah"></span> 

but can't further following xpath

//span[@class="speciallinktype"]/@onclick 

which returns

javascript:document.quickfindform.action 

any ideas on how pick out link inside of quickfindform.action xpath?

i tried xpath in java application , worked ok:

    import java.io.ioexception;     import java.io.stringreader;      import javax.xml.parsers.documentbuilder;     import javax.xml.parsers.documentbuilderfactory;     import javax.xml.parsers.parserconfigurationexception;     import javax.xml.xpath.xpath;     import javax.xml.xpath.xpathexpression;     import javax.xml.xpath.xpathfactory;      import org.w3c.dom.document;     import org.xml.sax.inputsource;     import org.xml.sax.saxexception;      public class teste {          public static void main(string[] args) throws exception {             document doc = stringtodom("<span onclick=\"javascript:document.quickfindform.action='/blah_blah'\" class=\"speciallinktype\"><img src=\"blah\"/></span>");             xpath newxpath = xpathfactory.newinstance().newxpath();             xpathexpression xpathexpr = newxpath.compile("//span[@class=\"speciallinktype\"]/@onclick");             string result = xpathexpr.evaluate(doc);             system.out.println(result);          }          public static document stringtodom(string xmlsource) throws saxexception, parserconfigurationexception, ioexception {             documentbuilderfactory factory = documentbuilderfactory.newinstance();             documentbuilder builder = factory.newdocumentbuilder();             return builder.parse(new inputsource(new stringreader(xmlsource)));         }     } 

result:

javascript:document.quickfindform.action='/blah_blah' 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -