开发者

xpath and self closing <br/>

Can anyone tell me how I can acc开发者_如何学运维ess the text after the < br / > in the following?

<li>
  <span class="title">Size</span>
  <p>Ladies<br />Case Diameter: 27.0 mm</p>
</li>

For some reason, I cannot get past it... however, I CAN get whats in front of it (Ladies)

Thanks!


Use:

/*/p/br/following-sibling::text()[1]

Do note the problem with the expression:

/li/p/br/following-sibling::text() 

Depending on the XML document this may select more than one (actually all) text-node following siblings of br, however you only want the text node that immediately follows br.


You can use:

/li/p/br/following-sibling::text()

You could also use:

/li/p/text()[2]

You may want to narrow it down to a specific "<p>" by using a predicate.


I am having the same issue with dirt xml closing tag. Eliminate the white space in <br /> and you will see it fixed. Thus, <br /> should be <br/>.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜