0

I executed the curl command in Linux, how can I list out the content of get_ccws_supportlist_t_json_T2Result one by one?

Command:

curl --request POST --header "Content-Type: text/xml;charset=UTF-8" -d @request.xml http://server1:5353/CCWS_IOC_interface.asmx | xmllint --format

Response:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org    /2001/XMLSchema">
  <soap:Body>
    <get_ccws_supportlist_t_json_Response xmlns="http://tempuri.org/">
      <get_ccws_supportlist_t_json_T2Result>[{"Sup_Team":"Team1","Sup_Project":"ID","Sup_Host":"host1","InstCluster":"loc1","SupSeq_id":"16186","SupSeq_Mode":"1","SupSeq_Seq":"1","SupSeq_Remark1":"Please call the support number directly instead of sending SMS.","SupSeq_Remark2":"","SupSeq_Remark3":"","Host_Location":"LOC1","Sup_ID":"1449","User_Team":"Team1","User_DomainID":"support1","User_Name":"Primary Production Support","User_Title":"T","Sup_InterfaceWith":"","Sup_Group":"2","SupGroup_Name":"Support"},{"Sup_Team":"T2","Sup_Project":"Team2","Sup_Host":"host2","InstCluster":"loc2","SupSeq_id":"813514","SupSeq_Mode":"0","SupSeq_Seq":"2","SupSeq_Remark1":"","SupSeq_Remark2":"","SupSeq_Remark3":"",    "Host_Location":"LOC2","Sup_ID":"2272","User_Team":"Team2","User_DomainID":"support2","User_Name":"Secondary","User_Title":"""Sup_InterfaceWith":"","Sup_Group":"2","SupGroup_Name":"Support"}]</get_ccws_supportlist_t_json_T2Result>
    </get_ccws_supportlist_t_json_Response>
  </soap:Body>
</soap:Envelope>
nd504
  • 19
  • 2
  • 1
    Are you trying to ask how to use `xmllint` to extract the JSON and run a JSON parser on it? Each in isolation is probably a common duplicate. Please search before asking. – tripleee May 18 '22 at 08:34
  • And probably https://stackoverflow.com/questions/48426052/how-to-extract-a-field-from-each-object-in-an-array-with-jq for the JSON part, though the problem statement there is slightly more complex; but just remove the parts you don't need, or at least use that as a pivot point for what to search for. – tripleee May 18 '22 at 08:36
  • @nd504 Use [tag:xidel]: `xidel -s -H "Content-Type: text/xml;charset=UTF-8" -d '{file:read-text("request.xml")}' "http://server1:5353/CCWS_IOC_interface.asmx" -e 'parse-json(//get_ccws_supportlist_t_json_T2Result)'`. That is, on the condition that it's valid JSON, because in your post `"User_Title":"""Sup_InterfaceWith"` is invalid and should be `"User_Title":"","Sup_InterfaceWith"`. – Reino Jun 11 '22 at 12:27

0 Answers0