When we use getXML over getXMLAnswer ??

Manikantahere
Tera Contributor

Performance wise and code wise community is suggesting to use getXmlAnswer when we are just depends on answer but most of the cases are same in terms of requirements I have seen.

 

so in which cases/business scenarios where we are compelled to use getXml over getXmlAnswer??

8 REPLIES 8

Hello @Manikantahere ,

 

Please refer to the thread below. I hope it provides a better understanding.

https://www.servicenow.com/community/developer-articles/getxmlanswer-vs-getxml/ta-p/2307589

 

Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.

 

Thanks and Regards,

Ashish

PrashantLearnIT
Giga Sage

Hi @Manikantahere 

 

This link will provide more insights - https://www.servicenow.com/community/developer-articles/getxmlanswer-vs-getxml/ta-p/2307589

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************

Juhi Poddar
Kilo Patron

Hello @Manikantahere 

 

The choice between using getXML() and getXMLAnswer() in ServiceNow depends on the complexity of the data returned by the server-side script, the structure of the response, and how you intend to handle that response on the client side.

Key Differences:

  • getXML(): Returns the entire XML response from the server-side script. It allows detailed parsing of the XML structure using DOM methods.
  • getXMLAnswer(): Extracts and returns only the <answer> element from the XML response. This is simpler and faster when you only need the result of the <answer> element.

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar

Even I can get list of values using getXmlAnswer right? 

for example if I want get user information by gliding user table  you are saying  we use getXml but can't I get user information using getXmlAnswer? 

 

if this is not the scenario where we need to use getXml let me know any good scenario for my understanding?

in real time what were the scenarios may I know?