1 Reply Latest reply on Nov 5, 2007 8:12 AM by JKohn99

    XML : how to save it back to server once edited

    southlondon Level 1
      Hi, i have written a newbie application that uses the Httpservice to call in a XML document. I have managed to display it in a tree, edit it by adding new nodes and children nodes. I would now like to resave the XML document in its edited form. Can someone point me in the direction of how i might accomplish this. Both the application and the XML would reside on a remote web server that can be logged into to gain access to the application and start editing the XML.

      Any thoughts ?

        • 1. Re: XML : how to save it back to server once edited
          JKohn99 Level 1
          Below is an example of sending building a request object with some
          xml, called requestXml. My example will do a post or get based on a user seletion.

          In this case the receiver is a servlet that looks for requestXml in the header.

          altServ = new HTTPService();
          altServ.resultFormat = "e4x";
          altServ.method = "POST";
          altServ.url=" http://lp008400:8080/FlexServletProject/servlet/FlexServlet"
          altServ.addEventListener(ResultEvent.RESULT,handleResult);
          altServ.addEventListener(FaultEvent.FAULT,handleFault);
          altServ.useProxy = false;

          var x:XML = new XML("<someRequest/>");
          x.@userId = "someuser id";
          x.@password = "some password";
          var c1:XML = new XML("<child/>");
          c1.@field1 = "parm1";
          c1.@field2 = "parm2";
          x.appendChild(c1);

          var request:Object = new Object();
          request.requestXml = x.toXMLString();
          request.parm1 = "someOtherParm";
          if(post.selected == true)
          altServ.method = "post";
          else
          altServ.method = "GET";
          altServ.send(request);
          //
          Servlet code:

          public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
          {

          response.setContentType("text/xml");

          String theRequest = request.getParameter("requestXml");
          }