Forum Discussion

dhiraj_gophane's avatar
11 years ago

How to catch and parse XML response generated from community event subscription notification?

Hi all, We are using endpoint url as a call-back url for messageCreate event. So whenever a message is created in community we get a response.   I think the response is in three parameters: 1. t...
  • YuriK's avatar
    11 years ago

    Hey Dhiraj,

     

    Unfortunately, we do not currently have a mechanism by which to convert an XML string to an object. I would suggest adding a suggestion on our Customer Ideas page. This leaves you with a few options.

     

    1) Use substring to get the information you want (not a great approach, but will work)

     

    <#assign msgNode = http.request.parameters.name.get("message","")/>
    
    <#if msgNode?length != 0>
      <#assign startString = '<id type="int">'>
      <#assign endString = '</id>'>
      <#assign startIndex = msgNode?index_of(startString)+startString?length>
      <#assign endIndex = msgNode?index_of(endString)>
    
      <#if startIndex != startString?length-1>
        <#if endIndex != -1>
    
          ${msgNode?substring(startIndex,endIndex)}
        </#if>
      </#if>
    </#if>

     2) Use javascript to convert the XML string to an object (it will then only be usable in javascript) (I haven't tried this yet, but it should work)

     

    There maybe other approaches that would work, but these were the 2 that popped to my mind.

     

    Hope this helps,

     

    Yuri