https://recalll.co/app/?q=xml%20-%20xmlstarlet%20select%20value


The key is to start from the ITEM node, not the identifyer:

Then you can pick out the bits you want:

$ xmlstarlet sel -t -c "/DATA/TABLES/ITEM[identifyer/@V=1234]/*" test.xml
<identifyer V="1234"/><property1 V="abcde"/><Property2 V="qwerty"/>

$ xmlstarlet sel -t -v "/DATA/TABLES/ITEM[identifyer/@V=1234]/Property2/@V" test.xml
qwerty

Great, that works :) Good to see the syntax in an example, I can get forward with this. Thanks!

xml - xmlstarlet select value - Stack Overflow

XML XMLSTARLET
1

View more

xml - xmlstarlet select value based on condition - Stack Overflow

XML XPATH XMLSTARLET
1

Use the following approach:

xmlstarlet sel -t -m "//DataRecord[@id='2']/*[self::Value or self::Timestamp]" -v . -n mbus-10.xml
1450
2017-04-28T05:35:09

xml - xmlstarlet select a value in the path under ...

XML XMLSTARLET
1

//x:types[starts-with(x:members,'PriceRule__c')]/x:name

and you will select the x:name with value, ListView, as requested.

thanks! This is what I was looking for!

I'm not clear on what the "x:" is for/represents in the example.

@BillHileman: It is a namespace prefix, defined by OP via -N in xmlstarlet to cover the default namespace in the XML document. See How does XPath deal with XML namespaces?

xml - xmlstarlet select sibling based on text value - Stack Overflow

XML XPATH XMLSTARLET
5

This XPath will select Value of a State based on its Key equalling state:

/FrontendStatus/State/String[Key='state']/Value

Or, in xmlstarlet:

$ xmlstarlet sel -t -m "/FrontendStatus/State/String[Key='state']" -v Value <status.xml

Will return WatchingLiveTV as requested.

xml - Select node by its text value in xmlstarlet - Stack Overflow

XML BASH XMLSTARLET
2

View more

xml - XMLStarlet: concatenate node values from different parents based...

XML CSV XSLT XMLSTARLET
2

View more

xml - XMLStarlet: concatenate node values from different parents based...

XML CSV XSLT XMLSTARLET
3

View more

Retrieving all attribute names of an XML element with xpath on xmlstar...

XML XPATH XMLSTARLET
11

View more

xslt - selecting an attribute value from an xml file - Stack Overflow

XML XSLT
2

View more

extracting nodes values with xmlstarlet - Stack Overflow

XMLSTARLET
3

View more

bash - Parse xml using shell tools like grep, awk or sed - Stack Overf...

BASH SHELL AWK SED
3

View more

bash - Parse xml using shell tools like grep, awk or sed - Stack Overf...

BASH SHELL AWK SED
0

View more

xml - Select node by its text value in xmlstarlet - Stack Overflow

XML BASH XMLSTARLET
0

View more

Parsing an xml with xmlstarlet - Stack Overflow

XML XMLSTARLET
0

View more

How to iterate over a xml file by xmlstarlet - Stack Overflow

XML XMLSTARLET
0

View more

xml - xmlstarlet Search Attribute - Stack Overflow

XML XPATH XML-PARSING XMLSTARLET
0

View more

xml - Select node by its text value in xmlstarlet - Stack Overflow

XML BASH XMLSTARLET
0

The key is to start from the ITEM node, not the identifyer:

Then you can pick out the bits you want:

$ xmlstarlet sel -t -c "/DATA/TABLES/ITEM[identifyer/@V=1234]/*" test.xml
<identifyer V="1234"/><property1 V="abcde"/><Property2 V="qwerty"/>
$ xmlstarlet sel -t -v "/DATA/TABLES/ITEM[identifyer/@V=1234]/Property2/@V" test.xml
qwerty

Great, that works :) Good to see the syntax in an example, I can get forward with this. Thanks!

xml - xmlstarlet select value - Stack Overflow

XML XMLSTARLET
0

View more

xml - Select node by its text value in xmlstarlet - Stack Overflow

XML BASH XMLSTARLET