I am using xmlstarlet library and i am trying to access to xml attribures from sh file.
AMOUNT= `cat $XML_FILE | xmlstarlet sel -t -m "//unjFeed/unjEntry/unjAmount" -o " " -v "."`
I am getting empty result. Any suggestion ? i am beginner in bash scripting
I had looked in documentation here http://xmlstar.sourceforge.net/doc/UG/ch04.html.
<unjFeed>
<unjEntry jackpotId="197993441" jackpotName="Power Jackpot">
<unjAmount curency="EUR" amount="50035.12"/>
<games>
<game id="558" name="Tycoons NJP Android"/>
<game id="559" name="Tycoons NJP Windows Phone"/>
<game id="556" name="Tycoons NJP"/>
<game id="557" name="Tycoons NJP Mobile"/>
<game id="555" name="Glam Life NJP"/>
<game id="567" name="At The Copa NJP Windows Phone"/>
<game id="566" name="At The Copa NJP Android"/>
<game id="565" name="At The Copa NJP Mobile"/>
<game id="564" name="At The Copa NJP"/>
<game id="563" name="Treasure Room NJP"/>
<game id="562" name="The Ghouls NJP"/>
<game id="561" name="Pharaoh King NJP"/>
<game id="560" name="Jackpot Jamba NJP"/>
<game id="575" name="Greedy Goblins NJP Windows Phone"/>
<game id="574" name="Greedy Goblins NJP Android"/>
<game id="573" name="Greedy Goblins NJP Mobile"/>
<game id="572" name="Greedy Goblins NJP"/>
<game id="571" name="Mr Vegas NJP Windows Phone"/>
<game id="570" name="Mr Vegas NJP Android"/>
<game id="569" name="Mr Vegas NJP Mobile"/>
<game id="568" name="Mr Vegas NJP"/>
<game id="576" name="Slots Angels NJP"/>
<game id="580" name="Good Girl, Bad Girl NJP"/>
<game id="581" name="Good Girl, Bad Girl NJP Mobile"/>
<game id="582" name="Good Girl, Bad Girl NJP Android"/>
<game id="583" name="Good Girl, Bad Girl NJP Windows Phone"/>
</games>
</unjEntry>
</unjFeed>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="unjFeed">
<xs:complexType>
<xs:sequence>
<xs:element name="unjEntry">
<xs:complexType>
<xs:sequence>
<xs:element name="unjAmount">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string" name="curency"/>
<xs:attribute type="xs:float" name="amount"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="games">
<xs:complexType>
<xs:sequence>
<xs:element name="game" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:short" name="id" use="optional"/>
<xs:attribute type="xs:string" name="name" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:int" name="jackpotId"/>
<xs:attribute type="xs:string" name="jackpotName"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Thanks in advance
cat jp.bak.xml | xmlstarlet sel -t -v "/unjFeed/unjEntry/unjAmount/@amount"
"/unjFeed/unjEntry/unjAmount/@amount" Is the access to attribute that called amount
The access as folders structure