We may come across a situation in which we are not sure of the namespace prefix of certain element. To retrieve such an element using XPATH we can use the wild character *
Example:
Say we have information of employees of an organization in an XML. XSD corresponding to employees.xml is employees.xsd. Also address details are separately defined in an XSD ,address.xsd and this XSD is referred in employees.xsd.
I am trying to access City of the first employee among multiple employees, and I do not know the namespace prefix of the Address element. Then I would write an Xpath as follow.
ns0:Employees/ns0:Employee[1]/*:Address/*:City/text()
This situation has helped me in writing an xquery expression in OSB.
However, it is always better to know what are all the namespaces and their prefixes that we are dealing with.
Example:
Say we have information of employees of an organization in an XML. XSD corresponding to employees.xml is employees.xsd. Also address details are separately defined in an XSD ,address.xsd and this XSD is referred in employees.xsd.
I am trying to access City of the first employee among multiple employees, and I do not know the namespace prefix of the Address element. Then I would write an Xpath as follow.
ns0:Employees/ns0:Employee[1]/*:Address/*:City/text()
This situation has helped me in writing an xquery expression in OSB.
However, it is always better to know what are all the namespaces and their prefixes that we are dealing with.
No comments:
Post a Comment