Answered by:
Read XML in Winforms from WebService

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
Michael- 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
Answers
-
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
- Proposed as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 30, 2011 9:10 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 30, 2011 9:10 AM
Wednesday, November 23, 2011 8:41 AM -
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.- Edited by Abhimanyu Sirohi Monday, November 21, 2011 5:42 AM added example link.
- Proposed as answer by Paul Zhou Tuesday, November 22, 2011 8:18 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 30, 2011 9:10 AM
Monday, November 21, 2011 5:41 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.
-Renjith
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.- Edited by Abhimanyu Sirohi Monday, November 21, 2011 5:42 AM added example link.
- Proposed as answer by Paul Zhou Tuesday, November 22, 2011 8:18 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 30, 2011 9:10 AM
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)writer.WriteStartDocument()
writer.WriteStartElement("Workers")For Each itm In col
writer.WriteStartElement("Worker")
writer.WriteAttributeString("Name", itm.FullName.ToString)
writer.WriteAttributeString("Ext", itm.Cell.ToString)
writer.WriteAttributeString("Photo", itm.Photo.ToString)
writer.WriteEndElement()
Nextwriter.WriteEndDocument()
writer.Flush()Dim xmlDocument As New XmlDocument()
xmlDocument.LoadXml(sb.ToString())
Return xmlDocument
End IfIs 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
MichaelTuesday, 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
- Proposed as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 30, 2011 9:10 AM
- Marked as answer by Ed Price - MSFTMicrosoft employee Wednesday, November 30, 2011 9:10 AM
Wednesday, November 23, 2011 8:41 AM