Best way to check if a node exists

Hi all,

i have the following problem: I got a XML document from our partner system and i want to check the existence of a specific node in this document. Actually, i use the service pub.xml.getLocalrootName.

Is it also possible to use the service pub.xml.queryXMLNode for this issue? Has anyone an idea for a possible XQL - Query String for this issue?



I usually use pub.xml:queryXMLNode to extract a node and then use a branch statement to determine whether the extracted node is null. If it is null, I deal with the error or if not, I convert it to a document for processing.

One way to determine your query is to trace through your service to your queryXMLNode service and then click on the “variables” tab to see the structure of the document. You can right-click on a node in the document and create a new variable with the query string. Just remove the /text() from the end and set the variable type to object. See the Built-In Services Guide for information on how to use queryXMLNode.

The XML Services Developer’s Guide has some information about XQL as well as the URL for the XQL spec. Also, there are several XQL-related posts here in the discussion forums.



Hi Mark,

thanks for your answer. But I think, my problem is an other one. I have attached a package that contains a service with two static variables. Each of the variables contains a SOAP - Message String. If I run the service with parameter toDo = KoSi.DeleteResponse, I will get a Exception from the server pub.xml.getXMLNodeType. The reason is, that the service pub.xml.documentToXMLString does not create a xmlstring with the namespace - value - as it is definded.

What can be the reason for this behaviour?

Thilo (8.5 k)


I think your question is “How do I determine the name of the root node inside the body of a soap message so that I know how to process it?”

Assuming that I have the right question, the answer is:

  1. If your soap message is in string form, first convert it to soapData form using the pub.soap.utils:stringToSoapData built-in service []Extract the body of the soap message into a node using the pub.soap.utils:getSoapBody built-in service []Map the “body” object (the soap body in node format) to the “node” input parameter of the pub.xml:queryXMLNode built-in service []Populate the “nsdecls” input parameter with a prefix that you want to use and the namespace of the soap body that you will be receiving. In the example that you sent, this would be populated with a prefix of “timb” and a namespace of “”. Note: You can use any prefix you want in this parameter but the value you use for namespace must match exactly with the one used in the soap message body []In the variables tab of the pub.xml:queryXMLNode service, create a variable called “nodeType” (or something similar) []Set the XQL query for this variable to //nodeName(). This XQL query will return the name of the node (without the prefix) that is this first and only child of the soap body. In your example, this would be either “Kunde.SearchResponse” or “Kunde.DeleteResponse” Now that you know the name of the root node in the body of the soap message you can process it appropriately. One way to use this is to determine which document type against which to validate the body before processing it.




thank you very much for your posting. This is the solution for my problem.

Good work!