我正在使用Enrich Mediator丰富的XML.
我的问题是,它总是适用于第一个元素,虽然我想将它应用于多个元素.如何将其应用于XPATH选择的所有元素?
我也试过下面的选项.但失败了.
//Response/ResponseDetails/SearchHotelPriceResponse/HotelDetails/Hotel[@HasExtraInfo="true"]
Run Code Online (Sandbox Code Playgroud)
丰富配置:
<enrich>
<source type="inline">
<ImageCode xmlns="">IMG10004</ImageCode>
</source>
<target action="child" xpath="//Response/ResponseDetails/SearchHotelPriceResponse/HotelDetails/Hotel[*]"/>
</enrich>
Run Code Online (Sandbox Code Playgroud)
XML有效负载:
<Response ResponseReference="REF_D_028_749-2801486459143247">
<ResponseDetails Language="en">
<SearchHotelPriceResponse>
<HotelDetails>
<Hotel HasExtraInfo="true" HasMap="true" HasPictures="true">
<City Code="LON">London</City>
<Item Code="ALE1">ALEXANDRA</Item>
<StarRating>3</StarRating>
<HotelRooms>
<HotelRoom Code="SB" NumberOfRooms="1"/>
</HotelRooms>
</Hotel>
<Hotel HasExtraInfo="true" HasPictures="true">
<City Code="LON">London</City>
<Item Code="ALO">Aloft London Excel</Item>
<StarRating>4</StarRating>
<HotelRooms>
<HotelRoom Code="SB" NumberOfRooms="1"/>
</HotelRooms>
</Hotel>
<Hotel HasExtraInfo="true" HasMap="true" HasPictures="true">
<City Code="LON">London</City>
<Item Code="AMB3">Ambassadors Bloomsbury</Item>
<StarRating>4</StarRating>
<HotelRooms>
<HotelRoom Code="SB" NumberOfRooms="1"/>
</HotelRooms>
</Hotel>
</HotelDetails>
</SearchHotelPriceResponse>
</ResponseDetails>
</Response>
Run Code Online (Sandbox Code Playgroud)
使用XPATH,我试图从以下内容中获取ISBN号:
<span class="product_info_details">
<b class="">ISBN: </b>1941529429
<b class="">Contributors: </b> (Illustrator)
<b class="">Publisher:</b> Parallax Pr
<b class="">Published:</b> Nov 1 2016
</span>
Run Code Online (Sandbox Code Playgroud)
现在,当我使用:
//span[@class="product_info_details"]/b/following-sibling::text()
Run Code Online (Sandbox Code Playgroud)
我得到输出:
1941529429
(Illustrator)
Parallax Pr
Nov 1 2016
Run Code Online (Sandbox Code Playgroud)
我可以使用什么,以便我得到第一个值(1941529429)作为结果?
我试图自动点击一些按钮的过程.虽然我走得很远,只有一个按钮无法工作.我正在使用python和selenium.所以我只想点击这个按钮,但我无法这样做.下面是我用css select和xpath试过的代码,但是我仍然无法点击它,我找不到错误路径.
这是我要点击的按钮
<button class="yt-uix-button yt-uix-button-size-default yt-uix-button-primary create-channel-submit" type="button" onclick=";return false;" data-channel-creation-token="GhaqucG9ARAKDi9teV92aWRlb3M_bz1VKAQ%3D"><span class="yt-uix-button-content">CREATE CHANNEL</span></button>
Run Code Online (Sandbox Code Playgroud)
我尝试了以下2个代码,但没有一个有效.
driver.find_element_by_xpath("//button[@class='button.yt-uix-button yt-uix-button-size-default yt-uix-button-primary create-channel-submit']").click()
driver.find_element_by_css_selector('button.yt-uix-button yt-uix-button-size-default yt-uix-button-primary create-channel-submit').click()
Run Code Online (Sandbox Code Playgroud) 可能问题很简单,但我只是坚持这个......我有以下XML
<?xml version="1.0" encoding="utf-8"?>
<InfoLinkDocument>
<HAWBUpdate>
<HAWBNumber>41665496563</HAWBNumber>
<HAWBDetails>
<HAWBWeight>2.56</HAWBWeight>
<HAWBWeightUnit>KG</HAWBWeightUnit>
</HAWBDetails>
</HAWBUpdate>
</InfoLinkDocument>
Run Code Online (Sandbox Code Playgroud)
我在我的XSL文件中有以下内容
<xsl:template match="/InfoLinkDocument">
<xsl:for-each select="HAWBUpdate">
<xsl:variable name="HAWBNumber" select="/HAWBNumber" />
<xsl:variable name="HAWBWeight" select="./HAWBDetails/HAWBWeight" />
<xsl:variable name="HAWBWeight2" select="//HAWBDetails/HAWBWeight" />
<xsl:variable name="HAWBWeight3" select="HAWBDetails/HAWBWeight" />
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)
但由于某种原因HAWBWeight,HAWBWeight2并且HAWBWeight3是空的.为什么?在这种情况下XPath应该是什么?
我有一个带有连续标签的XML文件,而不是嵌套标签,如下所示:
<title>
<subtitle>
<topic att="TopicTitle">Topic title 1</topic>
<content att="TopicSubtitle">topic subtitle 1</content>
<content att="Paragraph">paragraph text 1</content>
<content att="Paragraph">paragraph text 2</content>
<content att="TopicSubtitle">topic subtitle 2</content>
<content att="Paragraph">paragraph text 1</content>
<content att="Paragraph">paragraph text 2</content>
<topic att="TopicTitle">Topic title 2</topic>
<content att="TopicSubtitle">topic subtitle 1</content>
<content att="Paragraph">paragraph text 1</content>
<content att="Paragraph">paragraph text 2</content>
<content att="TopicSubtitle">topic subtitle 2</content>
<content att="Paragraph">paragraph text 1</content>
<content att="Paragraph">paragraph text 2</content>
</subtitle>
</title>
Run Code Online (Sandbox Code Playgroud)
我在BaseX中使用XQuery,我想将其转换为包含以下列的表:
Title Subtitle TopicTitle TopicSubtitle Paragraph
Irrelevant Irrelevant Topic title 1 Topic Subtitle 1 paragraph text 1
Irrelevant Irrelevant …Run Code Online (Sandbox Code Playgroud) 使用Selenium WebDriver,我可以在页面中找到所有Web元素的列表。我想编写一个函数,该函数将向我返回所传递元素的XPath字符串。
函数调用将类似于:
String XpathOfElement = myWebDriver.getXpath(My_Web_Element)
提示:-我认为我们可以使用javascript(使用JavaScriptExecuter)。但不熟悉javascript。
HTML结构是这样的:
<div class="image">
<a target="_top" href="someurl">
<img class="_verticallyaligned" src="cdn.translte" alt="">
</a>
<button class="dui-button -icon" data-shop-id="343170" data-id="14145140">
<i class="dui-icon -favorite"></i>
</button>
</div>
Run Code Online (Sandbox Code Playgroud)
提取文本的代码:
buyers = doc.xpath("//div[@class='image']/a[0]/text()")
Run Code Online (Sandbox Code Playgroud)
输出为:
[]
Run Code Online (Sandbox Code Playgroud)
我做错什么了?
我在Oxygen中启动了Xpath.在Xpath 3.0中找到了我需要但在Xquery 3.0中找不到的东西.
这是我的Xpath表达式
//table[tbody/tr/th/p[contains(text(), 'All Water System Contacts')]]/tbody/tr[3]/td[1]
Run Code Online (Sandbox Code Playgroud)
这是我的部分代码的xml代码.
<table border="1" cellpadding="1" cellspacing="1" summary="." width="640">
<tbody>
<tr>
<th colspan="3">
<p>All Water System Contacts </p></th>
</tr>
<tr>
<th>Type</th>
<th>Contact</th>
<th>Communication</th>
</tr>
<tr>
<td align="center">AC - Administrative Contact - GENERAL MANAGER </td>
<td align="center">GRANT, JOHN, W <br/> PO BOX 869<br/> BIG SPRING, TX 79721-0869 </td>
<td align="center">
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
width="100%">
<tbody>
<tr>
<th><b>Electronic Type</b></th>
<th><b>Value</b></th>
</tr>
</tbody>
</table>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse"
width="100%">
<tbody>
<tr>
<th><b>Phone …Run Code Online (Sandbox Code Playgroud) 我正在尝试遍历下拉列表进行网络抓取,但是我发现我的代码无法正常工作
dropdown = browser.find_element_by_XPATH('//*[@id="department-dropdown"]')
select = Select(dropdown)
select.select_by_value("Accounting")
Run Code Online (Sandbox Code Playgroud)
我收到的错误消息
Traceback (most recent call last):
File "C:\Users\David\eclipse-workspace\Web_Scrap\setup.py", line 31, in <module>
dropdown = browser.find_element_by_XPATH('//*[@id="mainContent"]/div[1]/div/div[3]/div/div/span')
AttributeError: 'WebDriver' object has no attribute 'find_element_by_XPATH'
Run Code Online (Sandbox Code Playgroud)
目前,我试图选择至少第一个值,但它没有解决问题
下拉框元素不是实际列表的一部分,这似乎有点令人困惑,有人可以让我知道这里的实际情况吗?如果我看错了。
如果有人对我可以怎样实现目标有任何建议
我试图通过其在iframe内的id获取'Form'元素的xpath.
在我查询时在chrome xpath插件中
// iframe中[含有(@ ID, 'fraModalPopup')]
它让我得到iframe,但当我尝试在层次结构中得到任何东西时,它只返回null.例如,如果我尝试做
// iframe [contains(@ id,'fraModalPopup')]/html //返回null
要么
// iframe [contains(@ id,'fraModalPopup')]/form [contains(@ id ='aspnetForm')] //不确定它是否是正确的xpath语句 - 也返回null
请任何人指导我如何抓住表单元素?我必须在RIDE(Robot Framework)中使用这个xpath.