none
Extract attachment from Stream RRS feed

  • Question

  • Frevvo form posts posts the data(xml and attachment) to the WCF RESTFul web service method. Stream also consists of an xml document, which is simply extracted as shown below. 

    Now it is required to extract the attachment from the Stream.

    //Read or extract XML doc from the Stream
    
                StreamReader sreader = new StreamReader(inStream);
                string xml = sreader.ReadToEnd();
                sreader.Close();
                int startPos = xml.IndexOf("<ns:form");
                int endPos = xml.IndexOf("</ns:form>");
    
                string data = xml.Substring(startPos, (endPos + 10) - (startPos));
    
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(data);

    Help or resources greatly appreciated.


    Apriori algorithm [association rule]

    Friday, January 11, 2013 5:00 AM

All replies

  • Maybe the attachments can be read in the same manner, but using other elements instead of “<ns:form>”? Check if xml string contains other data. Also check if attachments maybe are included into doc document.

    • Edited by Viorel_MVP Friday, January 11, 2013 1:15 PM
    • Proposed as answer by Mike FengModerator Monday, January 14, 2013 9:09 AM
    • Marked as answer by Mike FengModerator Friday, January 18, 2013 3:02 AM
    • Unmarked as answer by Raju Golla Monday, January 21, 2013 4:22 PM
    • Unproposed as answer by Raju Golla Monday, February 4, 2013 2:33 PM
    Friday, January 11, 2013 1:14 PM
  • Thanks Viorel.

    It is feasible to read the attachment similar to the above manner. Like help in finding the element, xml doc doesn't contain any attachment data.

    Further help appreciated.


    Apriori algorithm [association rule]

    Monday, January 14, 2013 10:25 AM
  • I am afraid that there is no such way to tell you which element contains attachment.

    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Tuesday, January 15, 2013 2:03 AM