Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

need help with XML Path syntax

Consider the following xml document below:

<?xml version="1.0" encoding="ISO-8859-1" ?>

<CALLINGNUMBERBERS>

     <CALLINGNUMBER ID='1'>

          <NUMBER>1234567890</NUMBER>

          <NAME>JONNY</NAME.

     </CALLINGNUMBER>

     <CALLINGNUMBER ID='2'>

          <NUMBER>8991234567</NUMBER>

          <NAME>JONNYHOME</NAME>

     </CALLINGNUMBER>

     <CALLINGNUMBER ID='3'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='4'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='5'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='6'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='7'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='8'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='9'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='10'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='11'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='12'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='13'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='14'>""</CALLINGNUMBER>

     <CALLINGNUMBER ID='15'>""</CALLINGNUMBER>

</CALLINGNUMBERBS>

I need to use the Get XML Document Data function to retrieve the following the number value and the name value as a string.  I understand that this has to be two separate requests.  It should be something like below.
"/descendant::CALLINGNUMBERS/child::CALLINGNUMBER[attribute::ID='" + callingNumberID.toString() + "']"

1 ACCEPTED SOLUTION

Accepted Solutions

Re: need help with XML Path syntax

Your two documents are different.  One has SOBERSTAFF (really?) as the root node, and one doesn't.  You may just be mixing up your documents.  If you're not, click the refresh icon on the document  in the repository.

Also, based on your last xml document posting this would net you the same:

//callingnumber[@id='1']/Number

//callingnumber[@id='1']/Name

The double forward slash indicates a search within the document

The [@key=value] indicates an attribute predicate match

The last /Number or /Name indicates a relative node select from the match preceding

You don't need all the descendant and child syntax in there either.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
6 REPLIES
New Member

Re: need help with XML Path syntax

So I found this great tool that let's me evaluate XPATH expressions against an XML doc.  The tool is here http://www.xmlme.com/XpathTool.aspx

Now using this tool and the following XPATH expression

"descendant::SOBERSTAFF/child::CALLINGNUMBERS/child::CALLINGNUMBER[attribute::ID=1]/child::NUMBER"

against the following XML DOC...

    

         

               1234567890

               JONNY

         

         

               8991234567

               JONNYHOME

         

          ""

          ""

          ""

          ""

          ""

          ""

          ""

          ""

          ""

          ""

          ""

          ""

          ""

    

    

          6412

          5551212

          ""

          ""

          ""

          ""

          ""

         

         

         

         

         

         

         

         

    

I'm able to get back the result that I want namely the value 1234567890 using the xpath query expression tool so my path is correct for the tool.  Now I can put this same expression into UCCX in the Get XML Document Data step and it accepts it.  But the value I get back is NULL when i run the script.  Very confused.

Message was edited by: WSonnylal

Re: need help with XML Path syntax

Your two documents are different.  One has SOBERSTAFF (really?) as the root node, and one doesn't.  You may just be mixing up your documents.  If you're not, click the refresh icon on the document  in the repository.

Also, based on your last xml document posting this would net you the same:

//callingnumber[@id='1']/Number

//callingnumber[@id='1']/Name

The double forward slash indicates a search within the document

The [@key=value] indicates an attribute predicate match

The last /Number or /Name indicates a relative node select from the match preceding

You don't need all the descendant and child syntax in there either.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Re: need help with XML Path syntax

Thanks for the help Anthony.  I tried it like you described and I'm still getting a NULL value response.  Not sure what it could be so I'm going to rebuild the XML file to see if it helps.

New Member

Re: need help with XML Path syntax

thanks Anthony your tip saved the day...

New Member

Re: need help with XML Path syntax

Thanks Anthony. Where did you pick up your knowledge of XML syntax? Any book you recommend, or Internet

resource? There is this http://www.w3.org/TR/xpath/, and it is great reference, but some examples would be good.

Re: need help with XML Path syntax

no books, just google  =)

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
795
Views
5
Helpful
6
Replies
CreatePlease login to create content