Home > OS >  How to retrieve data from an xml file?
How to retrieve data from an xml file?

Time:01-20

i have the below xml file. i need to retrieve the apithreshold value which is 1000 in this case. anyone know how can i do that on linux?

<TestPlan gui test testname="OrderQuery" enabled="true">
      <stringProp name="TestPlan.comments"></stringProp>
      <boolProp name="TestPlan.functional_mode">false</boolProp>
      <boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
      <boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
      <elementProp name="TestPlan.user_defined_variables" elementType="Arguments" gui test testname="User Defined Variables" enabled="true">
        <collectionProp name="Arguments.arguments">
            <elementProp name="secret" elementType="Argument">
              <stringProp name="Argument.name">secret</stringProp>
              <stringProp name="Argument.value">**</stringProp>
              <stringProp name="Argument.metadata">=</stringProp>
            </elementProp>
            <elementProp name="apithreshold" elementType="Argument">
              <stringProp name="Argument.name">apithreshold</stringProp>
              <stringProp name="Argument.value">1000</stringProp>
              <stringProp name="Argument.metadata">=</stringProp>
            </elementProp>
        </collectionProp>
      </elementProp>
      <stringProp name="TestPlan.user_define_classpath"></stringProp>
    </TestPlan>

CodePudding user response:

xmllint --xpath '//elementProp[@name="apithreshold"]/stringProp[@name="Argument.value"]/text()' file
-------8<------------------
1000
  • Related