XMLHelper in GlideAjax

Sean Duhaime
Giga Contributor

Hello everyone,

I am aware of how to use GlideAjax to return JSON, but for my own knowledge I am working on building out the same scripts just returning XML strings.   In my client script I need to convert that string to an object so that I can perform some action with it.   I found a Script Include in SN called XMLHelper that has a method called toObject() that does this.  

Unfortunately I am not having any success with it.   I wasn't sure if this Script Include could only be accessed server-side (I noticed that OOB in my PDI the "Client Callable" checklist is unchecked.   Just for fun I checked it and tried to call that method in my GlideAjax client script, to no success.  

Am I going about this all wrong?   Is XMLHelper not intended to be called by a client?   Is XMLHelper deprecated?

Thanks

1 ACCEPTED SOLUTION

Hi Sean,



Ok got it. But in ideal case you should parse the xmlstring in serverside. You can refer below links where they say they have done parsing in client side.



XML Client side?


Parse XML using JavaScript - Stack Overflow



If this helps to solve your query then please mark the answer as correct and also mark it as helpful.


Thanks in advance



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Sean,



Not sure what you are trying to achieve. if the script include which is Out of the box and is having client callable unchecked then there must be some purpose in having the client callable flag as unchecked. So avoid updating the out of box script includes etc



Below links you can go through:


XMLHelper - ServiceNow Wiki


ServiceNow — A few little scripting tricks I learned during an Application Development Training. | T...



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur.   My question is mostly academic.   I am just wondering if I should be able to call the XMLHelper from the client to parse an XML string into an object


Hi Sean,



Ok got it. But in ideal case you should parse the xmlstring in serverside. You can refer below links where they say they have done parsing in client side.



XML Client side?


Parse XML using JavaScript - Stack Overflow



If this helps to solve your query then please mark the answer as correct and also mark it as helpful.


Thanks in advance



Regards


Ankur


Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thank you Ankur, I think I was thinking about this all wrong.   I have left off trying to use XMLHelper on the client or server side.