/* rather than * in XPath selector predicate -
i read somewhere not able provide explanation issue, appreciate if can point me in right direction.
i creating xpath selectors canonical xpaths html docs. simple example below (enclosed in htmlunit uses xalan on background, can xpath processor).
if run:
webclient webclient = ......; htmlpage page = webclient.getpage("http://www.slideshare.com/"); system.out.println(page.getbyxpath("/html/body/footer/div/div/div[2]/div[4]/ul/li[2]/a[*]/text()")); i [] response. however, if run instead (mind a[ * ] vs a[ /* ]:
webclient webclient = ......; htmlpage page = webclient.getpage("http://www.slideshare.com/"); system.out.println(page.getbyxpath("/html/body/footer/div/div/div[2]/div[4]/ul/li[2]/a[/*]/text()")); i [developers section] response.
is possible in position predicate add wildcard argument (i.e. [ * ]). however, nodes/tags (i noticed particularly text nodes h1, h2..., p, b, strong , other html tags li or ul) slash required preceding wildcard (i.e. [ /* ]) results.
can please provide background mean? unable find reference on web or in xpath spec.
if intent in using "wildcard" select a occurs under path /html/body/footer/div/div/div[2]/div[4]/ul/li[2], don't need predicate @ all. can this:
/html/body/footer/div/div/div[2]/div[4]/ul/li[2]/a this select all a elements children of path /html/body/footer/div/div/div[2]/div[4]/ul/li[2].
Comments
Post a Comment