We have launched a free Basic Kubernetes Course. Click here to enrol now! Kubernetes is a container orchestration platform used by enterprises worldwide and Kubernetes developers are in high demand!
This article demonstrates how to read namespace related information using Woodstox StAX parser.
Create employee.xml as shown below.
Note the namespace URI ‘http://www.studytrails.com’ (see line 1 below) and the namespace prefix ‘s’ used in all start and end elements.
Create TestReadNamespace class as shown below.
Note that start element is obtained by using the StAX API (see lines 20-29 below).
The following API calls demonstrate reading of namespace related information:
- For the ’employee’ start element, get the namespace count (see line 22 below)
- Get the namespace prefix(see line 24 below)
- Get the namespace URI(see line 25 below)
The output of the program demonstrating how to read namespace related information is shown below: