gpt4 book ai didi

xml - 如何在R中将xpath用于多个xml属性

转载 作者:行者123 更新时间:2023-12-03 17:13:29 25 4
gpt4 key购买 nike

我想从xml文件中读取一些数据,并将这些数据嵌入到R脚本中,以便生成散点图。但是,问题是一个标签具有多个属性,
我不知道该如何处理。
请你能帮我吗?

例如,在下面的xml文件中,我想读取VertexConnectivity2的所有结果。也许我的其他问题和答案可以给您提示。

<?xml version="1.0" encoding="UTF-8"?>
<MappingTest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://sourceforge.net/projects/alevin/ ./Alevin.xsd" xmlns="http://sourceforge.net/projects/alevin/" name="AdvSubgraphTestGenerator2">
<TestGenerator className="tests.generatorTests.AdvSubgraphTestRunner"/>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="7.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="1612.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="1.6851389854194017"/>
<ScenarioMetric name="EdgeConnectivity2" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.9861088559313271"/>
<ScenarioMetric name="StochasticMetric2" result="0.7559889069056674"/>
<ScenarioMetric name="VertexConnectivity0" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="0.6648338346749284"/>
<ScenarioMetric name="EdgeConnectivity0" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="2.279045304613785"/>
<ScenarioMetric name="StochasticMetric0" result="0.4505067333055669"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="8.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="846.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="1.741814530894711"/>
<ScenarioMetric name="EdgeConnectivity2" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="1.0019396461682453"/>
<ScenarioMetric name="StochasticMetric2" result="0.868390100905683"/>
<ScenarioMetric name="VertexConnectivity0" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="1.854673959898261"/>
<ScenarioMetric name="EdgeConnectivity0" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="1.295691487310222"/>
<ScenarioMetric name="StochasticMetric0" result="0.6805885859898158"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="9.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="609.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.212517958069722"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.08677137867839191"/>
<ScenarioMetric name="StochasticMetric2" result="1.9927278019276755"/>
<ScenarioMetric name="VertexConnectivity0" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="1.6370875136672722"/>
<ScenarioMetric name="EdgeConnectivity0" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="1.8573960873462065"/>
<ScenarioMetric name="StochasticMetric0" result="1.7266332660325572"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="10.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="578.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.145412191385898"/>
<ScenarioMetric name="EdgeConnectivity2" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.826946783775961"/>
<ScenarioMetric name="StochasticMetric2" result="1.8202071941911595"/>
<ScenarioMetric name="VertexConnectivity0" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="1.5890364574294114"/>
<ScenarioMetric name="EdgeConnectivity0" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="2.2117994159315804"/>
<ScenarioMetric name="StochasticMetric0" result="1.1993780131111107"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="11.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="797.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.3954850079335364"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.019578501527560466"/>
<ScenarioMetric name="StochasticMetric2" result="3.0860109027715414"/>
<ScenarioMetric name="VertexConnectivity0" result="3.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="1.854555495387745"/>
<ScenarioMetric name="EdgeConnectivity0" result="3.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="3.584217996538307"/>
<ScenarioMetric name="StochasticMetric0" result="2.1648172533072234"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="12.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="892.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.4913004237744385"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.7696498939789347"/>
<ScenarioMetric name="StochasticMetric2" result="2.201723978314626"/>
<ScenarioMetric name="VertexConnectivity0" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="2.04191205905592"/>
<ScenarioMetric name="EdgeConnectivity0" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="2.376993537716656"/>
<ScenarioMetric name="StochasticMetric0" result="3.034262661127799"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="13.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="872.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.047126232292386"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.9952229587725951"/>
<ScenarioMetric name="StochasticMetric2" result="3.3794406500249257"/>
<ScenarioMetric name="VertexConnectivity0" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="1.6523543005400327"/>
<ScenarioMetric name="EdgeConnectivity0" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="3.048441149178422"/>
<ScenarioMetric name="StochasticMetric0" result="3.133358034963522"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="14.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="891.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="1.987660356945407"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.2484076205543828"/>
<ScenarioMetric name="StochasticMetric2" result="3.9080988222890496"/>
<ScenarioMetric name="VertexConnectivity0" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="2.1670218484160566"/>
<ScenarioMetric name="EdgeConnectivity0" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="3.2472187629267433"/>
<ScenarioMetric name="StochasticMetric0" result="3.1328785000072386"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="15.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="1162.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.2234619923069414"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.45771183680269933"/>
<ScenarioMetric name="StochasticMetric2" result="2.9215253413041196"/>
<ScenarioMetric name="VertexConnectivity0" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="2.054840069986192"/>
<ScenarioMetric name="EdgeConnectivity0" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="3.442550183039827"/>
<ScenarioMetric name="StochasticMetric0" result="3.995284651861695"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="16.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="1113.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.0926238844236447"/>
<ScenarioMetric name="EdgeConnectivity2" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.7808319615152142"/>
<ScenarioMetric name="StochasticMetric2" result="3.0087947748201787"/>
<ScenarioMetric name="VertexConnectivity0" result="1.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="2.1883371528470357"/>
<ScenarioMetric name="EdgeConnectivity0" result="1.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="3.663210710605434"/>
<ScenarioMetric name="StochasticMetric0" result="2.7728208750298773"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="17.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="2454.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="2.23606797749979"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.0"/>
<ScenarioMetric name="StochasticMetric2" result="4.143188604518091"/>
<ScenarioMetric name="VertexConnectivity0" result="4.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="3.2916550003635034"/>
<ScenarioMetric name="EdgeConnectivity0" result="4.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="2.7605883080698828"/>
<ScenarioMetric name="StochasticMetric0" result="5.220399731228472"/>
</ScenarioResult>
<ScenarioResult>
<ScenarioParameter name="Waxman_alpha" value="0.4"/>
<ScenarioParameter name="Waxman_beta" value="0.5"/>
<ScenarioParameter name="NumVNodesPerNet" value="18.0"/>
<ScenarioParameter name="NumVNets" value="1.0"/>
<ScenarioParameter name="SNetSize" value="100.0"/>
<ScenarioParameter name="Min_BW_Dem" value="10.0"/>
<ScenarioParameter name="Max_BW_Dem" value="50.0"/>
<ScenarioParameter name="Min_BW_Res" value="30.0"/>
<ScenarioParameter name="Max_BW_Res" value="100.0"/>
<ScenarioParameter name="Min_CPU_Dem" value="10.0"/>
<ScenarioParameter name="Max_CPU_Dem" value="50.0"/>
<ScenarioParameter name="Min_CPU_Res" value="30.0"/>
<ScenarioParameter name="Max_CPU_Res" value="100.0"/>
<ScenarioParameter name="NumberOfRun" value="1.0"/>
<ScenarioMetric name="Runtime" result="2516.0"/>
<ScenarioMetric name="RejectedNetworksNumber" result="0.0"/>
<ScenarioMetric name="VertexConnectivity2" result="2.0"/>
<ScenarioMetric name="AlgebraicConnectivity2" result="1.9840593925343335"/>
<ScenarioMetric name="EdgeConnectivity2" result="2.0"/>
<ScenarioMetric name="FabianianCoefficient2" result="1.0"/>
<ScenarioMetric name="SpectralGap2" result="0.3636812390986559"/>
<ScenarioMetric name="StochasticMetric2" result="4.238514242266579"/>
<ScenarioMetric name="VertexConnectivity0" result="3.0"/>
<ScenarioMetric name="AlgebraicConnectivity0" result="2.2503830421805113"/>
<ScenarioMetric name="EdgeConnectivity0" result="3.0"/>
<ScenarioMetric name="FabianianCoefficient0" result="1.0"/>
<ScenarioMetric name="SpectralGap0" result="4.0227880048448625"/>
<ScenarioMetric name="StochasticMetric0" result="6.649563197244915"/>
</ScenarioResult>
</MappingTest>

最佳答案

您可以将xmlGetAttrname = "result"一起使用:

library(XML)
doc <- xmlParse(xData)
res <- doc['//*[@name = "VertexConnectivity2"]'
, fun = function(x) xmlGetAttr(x, "result")]
> as.numeric(res)
[1] 1 1 2 1 2 2 2 2 2 1 2 2


或选择在xpath中选择 result属性:

library(XML)
doc <- xmlParse(xData)
> as.numeric(doc['//*[@name = "VertexConnectivity2"]/@result'])
[1] 1 1 2 1 2 2 2 2 2 1 2 2


要“选择NumVNodesPerNet =“ 14”,以使我只有NumVNodesPerNet = 14的vertexConnectivity2值,可以逐步进行分解。


查找属性为 name="NumVNodesPerNet"且属性为 value="14.0"的节点:

//*[@name="NumVNodesPerNet" and @value="14.0"]
从该节点返回到父节点:

/..
从该父节点中,选择具有属性 name = "VertexConnectivity2"的节点

/*[@name = "VertexConnectivity2"]
从我们的最终节点中选择结果属性

/@result


放在一起,我们有:

myXpath <- '//*[@name="NumVNodesPerNet" and @value="14.0"]/../*[@name = "VertexConnectivity2"]/@result'
> as.numeric(doc[myXpath])
[1] 2

关于xml - 如何在R中将xpath用于多个xml属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26687855/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com