Hitachi

JP1 Version 11 JP1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide 


10.3.36 getXmlAttrValue (obtains an attribute value of elements of XML data)

Syntax

getXmlAttrValue  [-e character-encoding]  element-name  attribute-name  [file-path-name]

Description

This command searches for element name from the XML file specified for argument and outputs all fully matched attribute values. Output is performed after deleting line breaks contained in attribute values.

Arguments

-e character-encoding
Windows edition

This command specifies the character encoding for XML files. "SJS" or "UTF8" can be specified. If you do not specify this option, the character encoding is treated as UTF8.

UNIX edition

This command specifies the character encoding for XML file with the syntax of value of the environment variable LANG. For values that can be specified, see 2.2.4 Encoding used in JP1/Advanced Shell.

If you do not specify this option, assume that the character encoding is specified in the format of the value of the LANG environment variable in the environment where JP1/Advanced Shell operates.

For example, if the XML file with the character encoding UTF-8 in AIX is treated, specify "JA_JP" or "JA_JP.UTF-8" for -e option.

element-name

This command specifies the element name with attribute.

attribute-name

This command specifies the attribute name to be searched.

file-path-name

This command specifies the path of a XML file. If you do not specify the file path name, input from the standard input.

Output to the standard output

Attribute values of elements of XML data.

Return codes

Return code

Meaning

0

Normal termination

Not less than 1

Termination with an error

Notes

Examples

XML data(data.xml)
<data>
  <city>
    <name id="0001" value="200">Yokohama</name>
    <name id="0002" value="100">Kawasaki</name>
  </city>
</data>

getXmlAttrValue name id data.xml
# The following contents are output:
0001
0002

getXmlAttrValue -e SJIS name value data.xml
# The following contents are output:
200
100