Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.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
如何查询xml(无效表达式)?_Xml_Xml Parsing_Xmlstarlet - Fatal编程技术网

如何查询xml(无效表达式)?

如何查询xml(无效表达式)?,xml,xml-parsing,xmlstarlet,Xml,Xml Parsing,Xmlstarlet,xml文件的一部分: <caldata chopper="on" gain_1="0" gain_2="0" gain_3="0" impedance="(0,0)"> <c0 unit="V">0.00000000e+00</c0> <c1 unit="Hz">4.00000000e-01</c1> <c2 unit="V/(nT*Hz)">1.93430000e-02</c2> <c3

xml文件的一部分:

<caldata chopper="on" gain_1="0" gain_2="0" gain_3="0" impedance="(0,0)">
  <c0 unit="V">0.00000000e+00</c0>
  <c1 unit="Hz">4.00000000e-01</c1>
  <c2 unit="V/(nT*Hz)">1.93430000e-02</c2>
  <c3 unit="deg">8.92260000e+01</c3>
</caldata>
<caldata chopper="on" gain_1="0" gain_2="0" gain_3="0" impedance="(0,0)">
  <c0 unit="V">0.00000000e+00</c0>
  <c1 unit="Hz">5.55800000e-01</c1>
  <c2 unit="V/(nT*Hz)">1.93390000e-02</c2>
  <c3 unit="deg">8.89710000e+01</c3>
</caldata>
<caldata chopper="on" gain_1="0" gain_2="0" gain_3="0" impedance="(0,0)">
  <c0 unit="V">0.00000000e+00</c0>
  <c1 unit="Hz">7.72300000e-01</c1>
  <c2 unit="V/(nT*Hz)">1.93320000e-02</c2>
  <c3 unit="deg">8.86030000e+01</c3>
</caldata>

0.00000000 E+00
4.00000000e-01
1.93430000e-02
8.92260000e+01
0.00000000 E+00
5.55800000e-01
1.93390000e-02
8.89710000e+01
0.00000000 E+00
7.72300000e-01
1.9332000E-02
8.86030000e+01
我想提取c2线上的数值。这是我的尝试:

 xmlstarlet sel -t -v '//caldata chopper="on"[<c2 unit="V/(nT*Hz)"> ]' 263.xml 
Invalid expression: //caldata chopper="on"[<c2 unit="V/(nT*Hz)"> ]
compilation error: element with-param
XSLT-with-param: Failed to compile select expression '//caldata chopper="on"[<c2 unit="V/(nT*Hz)"> ]'
 xmlstarlet sel -t -v '//caldata chopper="on"[<c2 unit="V/(nT*Hz)"> ]' 263.xml 
Invalid expression: //caldata chopper="on"[<c2 unit="V/(nT*Hz)"> ]
compilation error: element with-param
XSLT-with-param: Failed to compile select expression '//caldata chopper="on"[<c2 unit="V/(nT*Hz)"> ]'
xmlstarlet sel-t-v'//caldata chopper=“on”[]263.xml
无效的表达式://caldata chopper=“on”[]
编译错误:元素带有param
带参数的XSLT:未能编译选择表达式“//caldata chopper=”on“[]”
xmlstarlet sel-t-v'//caldata chopper=“on”[]263.xml
无效的表达式://caldata chopper=“on”[]
编译错误:元素带有param
带参数的XSLT:未能编译选择表达式“//caldata chopper=”on“[]”

我应该换什么?
xmlstarlet
是否适合此任务?

xmlstarlet非常适合此任务。尝试:

xmlstarlet sel -t -v '//caldata[@chopper="on"]/c2[@unit="V/(nT*Hz)"]' 263.xml
结果:

1.93430000e-02
1.93390000e-02
1.9332000E-02


xmlstarlet非常适合此任务。尝试:

xmlstarlet sel -t -v '//caldata[@chopper="on"]/c2[@unit="V/(nT*Hz)"]' 263.xml
结果:

1.93430000e-02
1.93390000e-02
1.9332000E-02