0

我有以下 HTML:

<div class=""postrow first"">
                <h2 class=""title icon"">
                    This is the title
                </h2>
                <div class=""content"">
                    <div id=""post_message_1668079"">
                        <blockquote class=""postcontent restore "">
                        <div>Category</div>
                            line 1<br /> line2
                        </blockquote>
                    </div>
                </div>
            </div>
            <div class=""postrow"">
                <h2 class=""title icon"">
                    second title
                </h2>
                <div class=""content"">
                    <div id=""post_message_1668079"">
                        <blockquote class=""postcontent restore "">
                        <div>Category</div>
                            line 1<br /> line2
                        </blockquote>
                    </div>
                </div>
            </div>

选择具有属性的所有 DIV的xpath字符串是“postrow”或“postrow”

4

1 回答 1

2

此答案假定对于每个"",您实际上"在文档中都有。

有许多可供您使用的替代 XPath。这里只有两个:

  • 使用条件|

    //div[@class = "postrow"] | //div[@class = "postrow "]

  • 使用starts-with

    //div[starts-with(@class, "postrow")]

于 2013-06-16T04:51:23.480 回答