I also posted this question on stack overflow, but none of the responses could solve my problem.
The problem is that I do not see passenger id value in the output. But, I see passenger printed. How do I fix this ?
Andy Jack wrote:I tried putting "passenger", "passenger id", "id" in both 26 and 31. It did not give me the value of id. What do I do now ?
In this example, the "id" component is *not* an element -- it is an attribute. So, you need to iterate through the attribute list that is passed to the element callback.
is the start tag of a "passenger" element. It contains an "id" attribute whose value is "001". If you interpreted it as an element whose name was "passenger id", then that wasn't correct. An XML element name can't contain whitespace.
It isn't illegal to put whitespace around the equal sign in an attribute, but almost nobody ever does that. Typically the tag would look like this:
That would make it a little more difficult for the unwary reader to mistake the meaning of the tag.
And by the way you shouldn't be using "equalsIgnoreCase" to compare an element name. In XML, element names are case-sensitive so "passenger" and "Passenger" are different things.
Andy Jack wrote:I also posted this question on stack overflow, but none of the responses could solve my problem.
And BTW, it looks like you also got an answer (with a code example) in your other topic -- so probably should mark this as resolved.