Hitachi

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


10.3.38 getXmlElem (obtains contents of elements of XML data)

Syntax

getXmlElem  [-e character-encoding]  element-name  [file-path-name]

Description

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

Arguments

-e character-encoding
Windows edition

This command specifies the character encoding for XML file. "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 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

Contents 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">Yokohama</name>
    <name id="0002">Kawasaki</name>
  </city>
</data>

getXmlElem -e SJIS name data.xml
# The following contents are output:
Yokohama
Kawasaki

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

getXmlElem city data2.xml | getXmlElem name
# The following contents are output:
Yokohama
Kawasaki