Read XML in Winforms from WebService RRS feed

  • Question

  • Hi. I am looking for correct sample where I can read xml in winform from my webservice which is return xml. I want use it to populate listbox or listview

    Thank you

    • Moved by Paul Zhou Thursday, November 24, 2011 8:26 AM off-topic (From:.NET Base Class Library)
    Sunday, November 20, 2011 9:44 AM


All replies

  • Hi Michael,

    What is the type returned by the web method ? is it XmlDocument ? If yes, you can use OuterXml property of XmlDocument. 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Sunday, November 20, 2011 1:29 PM
  • Because you say "read xml", I would suggest using XmlReader class to read your xml. If you want to run queries over your xml to extract data then your choose to use LINQ2XML which is implemented over XmlReader. See a comparison between LINQ2XML and XmlReader which will help you decide on the technology based on your requirements.

    And here an example.

    Click the 'Vote as Helpful' arrow if this post was helpful.
    Monday, November 21, 2011 5:41 AM
  • Hi. Thank you for respond. I am still looking  for full example to create xml in webservice and code for parsing. Here is my webmethod function


                If cls.GetData(col) Then     ' return 3 fields from sql server as a collection of custom class
                    Dim sb As New StringBuilder()
                    Dim writer As XmlWriter = XmlWriter.Create(sb)


                    For Each itm In col
                        writer.WriteAttributeString("Name", itm.FullName.ToString)
                        writer.WriteAttributeString("Ext", itm.Cell.ToString)
                        writer.WriteAttributeString("Photo", itm.Photo.ToString)


                    Dim xmlDocument As New XmlDocument()
                    Return xmlDocument
               End If


    Is it correct way to return XML?

    I will appreciated for working example where my source xml is not stored file but webservice result


    Thank you a lot

    Tuesday, November 22, 2011 8:58 AM
  • Hi Michael,


    Welcome to the MSDN forum.


    According to your description, I'm afraid it is a problem related to XML development in WebService. You may post thread in WCF, ASMX and other Web Services forum to get better support.



    Thank you for your posting and understanding.

    Have a nice day.

    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, November 23, 2011 8:41 AM