python 读xml xml path 写法。
来源:互联网 发布:淘宝网 电脑版 编辑:程序博客网 时间:2024/05/17 23:21
<?xml version="1.0" encoding="UTF-8"?>
<XMLTool>
<DataFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Data.xml</DataFilePath>
<ScenariosFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Scenarios.xml</ScenariosFilePath>
<SelectAllDataPreparationDataRows>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row/@isEnabled</DataRowsXpath>
</SelectAllDataPreparationDataRows>
<RemoveAllEmptyRows>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row</DataRowsXpath>
</RemoveAllEmptyRows>
<AddTheTestURLForAllScenaios>
<Mode>ADDURL</Mode>
<ScenaiorsXpath>//Scenario/@url</ScenaiorsXpath>
<AddedURL>234</AddedURL>
</AddTheTestURLForAllScenaios>
<RemoveScenariosURL>
<ScenariosXpath>//Scenario/@url</ScenariosXpath>
</RemoveScenariosURL>
<SelectAllRegressionScenarios>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/@isEnabled</DataRowsXpath>
</SelectAllRegressionScenarios>
<ChangeOrder>
<TargetScenarioName>RT_Import Entity -AccountCSVError</TargetScenarioName>
</ChangeOrder>
<SelectAllSteps>
<Mode>SELECTALL</Mode>
<ScenariosStepsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/Steps/Step/@isEnabled</ScenariosStepsXpath>
</SelectAllSteps>
<UnSelectAllScenarios>
<ScenariosXpath>//Scenarios/Scenario/@isEnabled</ScenariosXpath>
</UnSelectAllScenarios>
<SelectYourFirm>
<DataRowsXpath>//Table[@name='Login Password']/Rows/Row</DataRowsXpath>
<Name>jack</Name>
</SelectYourFirm>
<XMLTool>
<DataFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Data.xml</DataFilePath>
<ScenariosFilePath>C:/jack/d/workspace/Bam_Test/BAM Testing_Scenarios.xml</ScenariosFilePath>
<SelectAllDataPreparationDataRows>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row/@isEnabled</DataRowsXpath>
</SelectAllDataPreparationDataRows>
<RemoveAllEmptyRows>
<DataRowsXpath>//Table[contains(@name,'Data Preparation')]/Rows/Row</DataRowsXpath>
</RemoveAllEmptyRows>
<AddTheTestURLForAllScenaios>
<Mode>ADDURL</Mode>
<ScenaiorsXpath>//Scenario/@url</ScenaiorsXpath>
<AddedURL>234</AddedURL>
</AddTheTestURLForAllScenaios>
<RemoveScenariosURL>
<ScenariosXpath>//Scenario/@url</ScenariosXpath>
</RemoveScenariosURL>
<SelectAllRegressionScenarios>
<Mode>SELECTALL</Mode>
<DataRowsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/@isEnabled</DataRowsXpath>
</SelectAllRegressionScenarios>
<ChangeOrder>
<TargetScenarioName>RT_Import Entity -AccountCSVError</TargetScenarioName>
</ChangeOrder>
<SelectAllSteps>
<Mode>SELECTALL</Mode>
<ScenariosStepsXpath>//Scenarios/Scenario[contains(@name,'RT_')]/Steps/Step/@isEnabled</ScenariosStepsXpath>
</SelectAllSteps>
<UnSelectAllScenarios>
<ScenariosXpath>//Scenarios/Scenario/@isEnabled</ScenariosXpath>
</UnSelectAllScenarios>
<SelectYourFirm>
<DataRowsXpath>//Table[@name='Login Password']/Rows/Row</DataRowsXpath>
<Name>jack</Name>
</SelectYourFirm>
</XMLTool>
import xml.etree.ElementTree as ETimport osdef getXMLConfigNodeText(filePath,xPath): if (os.path.isfile(filePath)==False): return; root=ET.parse(filePath).getroot(); nodetext=root.find(xPath).text if (nodetext==""): print("please check the node name is right!") #print(nodetext) return nodetextimport ReadXmlConfigif __name__ == '__main__': scenarioFilePath=ReadXmlConfig.getXMLConfigNodeText("C:/HackXMLConfig.xml","ScenariosFilePath") xpath=ReadXmlConfig.getXMLConfigNodeText("C:/HackXMLConfig.xml","AddTheTestURLForAllScenaios/ScenaiorsXpath") url=ReadXmlConfig.getXMLConfigNodeText("C:/HackXMLConfig.xml", "AddTheTestURLForAllScenaios/AddedURL") print(scenarioFilePath) print(xpath) print(url)
默认 getroot =XMLTool 所以 第一可以写成 ScenariosFilePath ,默认root 可以省略。
- python 读xml xml path 写法。
- xml写法
- xml path
- 用python读取xml文件的写法举例
- Tomcat Web.xml写法
- sitemap.xml的写法
- PullToRefreshListView xml 写法
- log4j.xml的写法
- android selector.xml写法
- mybatis xml写法
- hibernate二级缓存(xml写法)
- python学习之os.path模块&&elementtree处理xml文件
- python minidom读xml
- python 读xml文件
- python minidom读xml
- FOR XML PATH
- for xml path(string)
- build.xml中的path
- english - word - 20110129
- 21.VC(ui)-DIB段
- 2012-Linux->22(从一个男人身上看出他的修养和抱负)
- dos cd命令(非原创)
- Web组件分离
- python 读xml xml path 写法。
- 分布式缓存
- base-hardware-graph
- Google解决Android屏幕尺寸问题
- Ajax原理介绍
- oracle数据库的一些时间加减操作
- 反向代理缓存
- 使用SharePoint 2010模式对话框
- PHP 安全手册 第七条 文件上传操作进行规避一些风险