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
-
If matching elements or attributes are not found, the command terminates with an error.
-
If metacharacter in the regular expression is included in the element name or attribute name, specify the element name by escaping with \.
- Example:
-
This command is specified as follows when you search for the attribute name "id*" in the element name "name+".
getXmlAttrValue 'name\+' 'id\*' test.xml
-
This part creates a temporary file by using the adshmktemp command. Therefore, the temporary file might remain when the command receives a forced termination request while the part is being executed. In this case, delete the temporary file manually. Temporary file is created in the directory defined with the TEMP_FILE_DIR parameter of the temporary file according to the following naming rule:
getXmlAttrValue_job-ID_process-ID_time-information_file-sequence-number
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