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

Attention: The Community will be in read-only mode on 12/14/2017 from 12:00 am pacific to 11:30 am.

During this time you will only be able to see content. Other interactions such as posting, replying to questions, or marking content as helpful will be disabled for few hours.

We apologize for the inconvenience while we perform important updates to the Community.

New Member

UCCX 8.5.1 "Get XML Document Data" always returns the data of the first record

Hello Support Cummunity,

i have a XML file with the following content:

<csv_data_records>

     <record>

          <title/>

          <firstname>numberone</firstname>

          <lastname>numberone</lastname>

          <phone>11111</phone>

     </record>

     <record>

          <title/>

          <firstname>number2</firstname>

          <lastname>number2</lastname>

          <phone>22222</phone>

     </record>

     <record>

          <title/>

          <firstname>number3</firstname>

          <lastname>number3</lastname>

          <phone>33333</phone>

     </record>

</csv_data_records>

my "Get XML Document Data" looks like this:   "/descendant::csv_data_records/child::record/child::phone"

in the first round it returns 11111 as phone number, thats ok, if this doesnt match to the caller i make a loop and make the "Get XML Document Data" a second time, but then it also returns 11111.

i remember it from the UCCXD Course that this works if i use a SQL Server. but why doesn't it work with XML?

with SQL Server it recognizes itself that this is the second query and returns the second value...

is there a hint to also achieve this with XML?

Everyone's tags (4)
6 REPLIES

Re: UCCX 8.5.1 "Get XML Document Data" always returns the data o

You have to use an XPATH predicate like this:

//record[1]

//record[2]

etc.

Therefore, your xapth needs to be built at run time like this:

label Get Next Record

increment i

xpath_record = "//record[" + i + "]"

xpath_result = Get XML Document Data (xml_doc, xpath_record)

if (xpath_result != null && xpath_result.trim() != "")

  true

    /* Data Found - Store the data in the record variable */

    set record = xpath_result

    ...Your record processing steps go here...

    goto Get Next Record

  false

    /* No Data Found - End the loop */

    goto End of Record Set

label End of Record Set

Source for more info: http://www.w3schools.com/xpath/xpath_syntax.asp

EDIT: Added more detail to the script example.

Anthony Holloway

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

Re: UCCX 8.5.1 "Get XML Document Data" always returns the data o

ok thank you Anthony, i will try that.

Re: UCCX 8.5.1 "Get XML Document Data" always returns the data o

Please write back and let everyone know if it worked, and if so, mark this solution as solved so others know if this is a good solution to follow or not.  Thanks.

Anthony Holloway

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

UCCX 8.5.1 "Get XML Document Data" always returns the data of th

This doesn't seem to work for me.  I have tried several variations of XPath, but [2] or more always comes up "null", even though the XML Document contains multiple records.

When calling record[1]. I pull up the first data.  No problems.  but, calling record[2] or record[3] or more, always just shows up null data.

I've tried using the absolute path (i.e. /descendant::root/child::childnode/child::datafield[2]).  i've also tried ( //datafield[2] ).

None seem to work.  Always come up null.  But, when i debug, and I look at the XML Document that I'm parsing, I verified all the nodes are there.

New Member

Re: UCCX 8.5.1 "Get XML Document Data" always returns the data o

I found the problem.  Using this XML as example:

 

    Boring Stuff

    Boring Stuff2

 

    Cool Stuff

    Cool Stuff2

 


Now, using //data1[1] and using //data1[2] should work, but it didn't for me.   Instead, I had to use the array at the "Record" level rather than the data level.  In other words, to get both "Boring Stuff" and "Cool Stuff", I had to use the following XPath:

/descendant::Parent/child::Record[1]/child::data1

and

/descendant::Parent/child::Record[2]/child::data1

So, if I were to modify Anthony's script above:

label Get Next Record
increment i
xpath_record = "/descendant:Parent/child::Record[" + i + "]/child::data1"
xpath_result = Get XML Document Data (xml_doc, xpath_record)
if (xpath_result != null && xpath_result.trim() != "")
  true
    /* Data Found - Store the data in the record variable */
    set record = xpath_result
    ...Your record processing steps go here...
    goto Get Next Record
  false
    /* No Data Found - End the loop */
    goto End of Record Set
label End of Record Set


New Member

The i increment should work

The i increment should work if you need an actual exemple:

4557
Views
5
Helpful
6
Replies
CreatePlease to create content