我有HTML页面,如:
...
// Product 1
<div class="lst_main">
<a href="link1.html">
<span> Product 1 name </span>
<div class="lst_meta">
<span> Product1 $price</span>
</dev>
</div>
// Product 2
<div class="lst_main">
</div>
....
// Product N
<div class="lst_main">
</div>
....
Run Code Online (Sandbox Code Playgroud)
我需要获取每个产品的URL,名称和价格.对于这个任务,我使用Kanna lib,这里是我的代码:
let myURLString = "https://url/to/page"
let myURL = URL(string: myURLString)
do {
let myHTMLString = try String(contentsOf: myURL, encoding: .ascii)
if let doc = HTML(html: myHTMLString, encoding: .utf8) {
for product in doc.xpath("//div[@class='lst_main']") {
print(product.text)
}
}
} catch let error {
print("Error: \(error)") …Run Code Online (Sandbox Code Playgroud) 我需要返回dependentAssembly的代码库属性(即,asmv1:assembly => Dependency => dependentAssembly(第一个)=> codebase属性)
这是XML文件:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2">
<assemblyIdentity name="program.application" version="3.4.95.1045" publicKeyToken="98ecb8aa8cf73f16" language="neutral" processorArchitecture="msil" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="publisher" asmv2:product="Magical Christmas Land" xmlns="urn:schemas-microsoft-com:asm.v1">Magical Christmas Land</description>
<deployment install="true" minimumRequiredVersion="3.4.95.1045" co.v1:createDesktopShortcut="true">
<subscription>
<update>
<beforeApplicationStartup />
</update>
</subscription>
</deployment>
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<framework targetVersion="4.5.2" profile="Client" supportedRuntime="4.0.30319" />
<framework targetVersion="4.5.2" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="3.0.8\program.exe.manifest" size="214085">
<assemblyIdentity name="program.exe" version="3.0.8" publicKeyToken="48ecb8aa8cf73f16" language="neutral" processorArchitecture="msil" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" …Run Code Online (Sandbox Code Playgroud) 我有一个响应式设计,我需要与之交互的很多项目都有2个WebElements.一个用于桌面,一个用于移动,我正在尝试使用PageFactory.以下是我现在要识别并与元素交互的内容.
//this returns 2 webelements, one for desktop and one for mobile
@FindBy(xpath = "//selector-dropdown/p")
private WebElement dropdown;
public void ClickDropdown() throws InterruptedException {
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.visibilityOf(dropdown)).click();
}
Run Code Online (Sandbox Code Playgroud)
我的印象是ExpectedConditions.visibilityOf(WebElement)会发现第一个元素可见.现在,当我在桌面上打开应用程序时,它会找到该元素(桌面是DOM中的第一个).但是在移动设备上,它等待可见性超时,因为它等待第一个变得可见.
我的另一种方法是使用@FindBy来声明每个元素两次,然后创建一个if语句来决定采用哪个路径.这项额外的工作是否能使其发挥作用?
查询:
let $collection := "sampledata"
for $uri1 in cts:uris((),(),(
cts:element-query(xs:QName("root"),
cts:and-query((
cts:element-attribute-value-query(xs:QName("root"),xs:QName($value1),$value2),
cts:element-attribute-value-query(xs:QName("root"),xs:QName($value3),$value4),
cts:element-value-query(xs:QName("year"),$value5),
cts:element-value-query(xs:QName("month"),$value6),
cts:element-attribute-value-query(xs:QName("num"),xs:QName("value"),$value7)
)))) )
return $uri1
Run Code Online (Sandbox Code Playgroud)
如何在上面提到的xquery中添加集合名称.
假设我有一个XML-
<SearchPage ID="123" version="1.3" xmlns="http://some/path">
.....some child elements
</SearchPage>
Run Code Online (Sandbox Code Playgroud)
如何从中获取所有属性名称?
解析HTML文件时有没有办法使用xpath?
我正在寻找一个Ruby Nokogiri等价物,但Crystagiri没有实现它(但是?).也试过myhtml和谦虚但无济于事.
我在PHP5.4上运行以下行没有任何问题:
$lstContent = $data->xpath("/response/lst[@name='highlighting']")[0]->lst[$i]->arr->str;
Run Code Online (Sandbox Code Playgroud)
但是现在在PHP5.3(生产系统)上我收到以下错误:
解析错误:语法错误,第153行的/var/www/html/upload/inc_suche_code.php中的意外'['
有什么想法快速解决?更新PHP对我不起作用.
我举个例子
<a href="target.php">News</a>
<a href="more.php">More</a>
Run Code Online (Sandbox Code Playgroud)
用XPath 提取href基于<a></a>(原子数据)之间的值的最有效方法是什么
我有一个带有多个节点的XML文件,如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="eating">
<title lang="en">Everyday Italian</title>
<author>Giada</author>
<year>2015</year>
</book>
</bookstore>Run Code Online (Sandbox Code Playgroud)
我想要使用XPATH进行类别烹饪的书籍中的子节点数。
就像上面的例子一样,带有属性烹饪的子节点的数量为4
在MouseEvent实例上,我们有一个称为path的属性,它可能看起来像这样:
有人知道是否存在将此路径数组转换为XPath的可靠方法吗?我认为此路径数据是最好的起点?我可以使用图书馆进行转换吗?
这个库看起来很有前途,但是它不使用事件的path属性:https : //github.com/johannhof/xpath-dom