C# html中的Xpath选择器问题

C# html中的Xpath选择器问题,c#,xpath,html-agility-pack,C#,Xpath,Html Agility Pack,我在从两个peace的html中获取Xpath时遇到了问题,但它们显示相同的信息 标记一个 <td class="tdRow1Color" width="100%"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr><td class="plaintextbold">Item Number:&nbsp;1258</td></tr

我在从两个peace的html中获取Xpath时遇到了问题,但它们显示相同的信息

标记一个

<td class="tdRow1Color" width="100%">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
    <tr><td class="plaintextbold">Item Number:&nbsp;1258</td></tr>
        <tr><td><img alt="" src="images/clear.gif" width="1" height="10" border="0"></td></tr>
    <tr>
        <td class="plaintext" valign="middle">&nbsp;<img src="../images/0note.gif" border="0" align="absmiddle">&nbsp;<a class="prodlink" href="writeReview.asp?number=1258"><i><u>Be the first to review this item</u></i></a></td>
            </tr>   
                <tr><td><img alt="" src="images/clear.gif" width="1" height="10" border="0"></td></tr>                    
         <tr><td class="plaintext"><b>RRP £50.00 - Now £39.99</b>          </td>
但这似乎不起作用,我只是想知道,当他们有
的时候,以及当它正好在
RRP之后时,有没有办法获得RRP价格。感谢您提供的任何建议

您的输入HTML中有几个
,而不仅仅是RRP。因此,我建议您在XPath中的文本节点开头测试“RRP”字符串

在这两种情况下,类似的方法都应该有效:

//td[@class='tdRow1Color']//td[@class='plaintext']//text()[starts-with(., 'RRP')]

以下XPath适用于我:

( //td[@class='tdRow1Color']/descendant::td[last()] | //td[@class='tdRow1Color']/descendant::b[last()] )/text()
//td[@class='tdRow1Color']//td[@class='plaintext']//text()[starts-with(., 'RRP')]
( //td[@class='tdRow1Color']/descendant::td[last()] | //td[@class='tdRow1Color']/descendant::b[last()] )/text()