html - How to get the value(only) of an attribute using xpath? -
i have question using xpath value of attribute. know using @
can attributename-value pair, if want value?
let me give example: fr link: http://www.campbellskitchen.com/?pd=yes&sekw=10941064280
if utilize chrome , utilize $x("//a[contains(.,'brand')]/following-sibling::div//a/@title")
it homecoming me array of this:
[title="campbell's condensed soup", title="campbell's gravies", title="swanson broth , stock" ...]
this not want, want homecoming array be:
[campbell's condensed soup, campbell's gravies, swanson broth , stock ...]
<li role="menuitem" class="parent"><a href="/brands?fm=link_navigated" title="brands" role="link" tabindex="10" accesskey="b"> brands</a> <div class="subnavi dropdown_5columns"> <!-- begin 5 columns container --> <div class="ddheader"> <div class="leftcorner"> <div class="rightcorner"> </div> </div> </div> <div class="leftshadow"> <div class="rightshadow"> <div class="ddcontent clearfix"> <div class="col_1_logo"> <a href="/wisestkid/home?fm=link_navigated" title="campbell’s® condensed soup"> <img width="65" height="27" alt="campbell’s® condensed soup" src="~/media/ourbrands/logos/campbells.ashx?mh=38&mw=65"></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_0" title="campbell's® gravies" href="/brands/campbells%20gravies?fm=link_navigated"><img src="/~/media/ourbrands/logos/campbells_gravy.ashx?h=38&mh=38&mw=65&w=57" alt="campbells gravy" width="57" height="38" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_1" title="swanson® broth , stock" href="http://www.campbellskitchen.com/swanson/home.aspx?fm=theater"><img src="/~/media/ourbrands/logos/swansonfb_llogo.ashx?h=36&mh=38&mw=65&w=65" alt="swanson" width="65" height="36" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_2" title="pace® sauces" href="/brands/pace%20sauces?fm=link_navigated"><img src="/~/media/ourbrands/logos/pace.ashx?h=38&mh=38&mw=65&w=60" alt="pace" width="60" height="38" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_3" title="prego® sauce" href="/brands/prego%20sauce?fm=link_navigated"><img src="/~/media/ourbrands/logos/prego.ashx?h=25&mh=38&mw=65&w=65" alt="prego" width="65" height="25" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_4" title="pepperidge farm®" href="/brands/pepperidge%20farm?fm=link_navigated"><img src="/~/media/ourbrands/logos/pepperidge_farm.ashx?h=22&mh=38&mw=65&w=65" alt="pepperidge farms" width="65" height="22" /></a> </div> <div class="col_1_logo"> <a id="plhheader_0_rptbrands_lnkbrand_5" title="soup plus" href="/brands/soup%20plus?fm=link_navigated"></a> </div> <div class="col_3"> <a href="/brands?fm=link_navigated" title="see our brands"> see our brands</a> </div> </div> <!-- ddcontent --> </div> </div> <div class="ddfooter"> <div class="leftcorner"> <div class="rightcorner"> </div> </div> </div> </div> <!-- end 5 columns container --> </li>
$x
returns selected dom nodes, if want extract info nodes you'll have in javascript sec step, e.g.
$x(somexpath).map(function(n) { homecoming n.nodevalue; });
html xpath
No comments:
Post a Comment