Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/290.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在XPath(PHP)中使用诸如jQuery之类的css选择器_Php_Xpath_Css Selectors - Fatal编程技术网

如何在XPath(PHP)中使用诸如jQuery之类的css选择器

如何在XPath(PHP)中使用诸如jQuery之类的css选择器,php,xpath,css-selectors,Php,Xpath,Css Selectors,首先,我有一个很好的指南作为XPath的参考: 但是,我无法在DOM中找到我要查找的内容。 例如,假设我们有以下DOM: <body> <div id="main"> <div class="preheader"></div> <div class="description"></div> <div class="productbox">

首先,我有一个很好的指南作为XPath的参考:

但是,我无法在DOM中找到我要查找的内容。 例如,假设我们有以下DOM:

<body>
    <div id="main">
        <div class="preheader"></div>
        <div class="description"></div>
        <div class="productbox">    
            <div class="content"></div>
        </div>
    </div>
    <div class="content"></div>
</body> 
我必须如何使用上面分享的指南编写它?

这里是xpath

//div[@id='main']//div[@class='producybox']/div[@class='content']
xpath的通用表示法

//div[@id='main']//div[@class='producybox']/div[@class='content']
带有单个属性的xpath
//标记[@attribute='attribute\u value']


具有多个属性的xpath:
//tag[@attribute1='attribute1\u value'和@attribute2='attribute2\u value']

如果您正在寻找等效的xpath
//div[@class='producybox']/div[@class='content']
@supputuri
#main
id属性如何?请检查我的答案。@此处使用的Alejandro xpath唯一地标识元素,因此
/*[@id='main']
是可选的。