0

I am able to read the xml file into dataset. Currently it is printing in a string format. Is it possible to print in xml format from web method call. I want to publish through dataset.writexml

Public Function HelloWorld() As String
    Dim dsProducts As New DataSet()
    Dim swriter As New IO.StringWriter

    dsProducts.ReadXml(AppDomain.CurrentDomain.BaseDirectory & "\Product.xml").ToString()
    dsProducts.WriteXml(swriter)

    Return swriter.ToString()
End Function

Is it possible with XMLTextWriter?

CPK_2011
  • 872
  • 3
  • 21
  • 57

2 Answers2

0

Take a look at Xdoc. Your method can return an XML document instead of a string. Also this answer will probably help you reach your solution.

Community
  • 1
  • 1
Keith Beard
  • 1,601
  • 4
  • 18
  • 36
0

Create an XMLDocument object and call LoadXML(yourXMLString). http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.loadxml

This will load that string into that object and from there, you can save the XML to a file. Is that what you're looking for?

EDIT:

The DataSet class has a GetXML() method which returns the XML String that you can pass to your webservice. Is that what your webservice is expecting? An XML string?

http://msdn.microsoft.com/en-us/library/system.data.dataset.getxml

Yatrix
  • 13,361
  • 16
  • 48
  • 78
  • On click of HelloWorld and invoke, it should display the data in xml format so that i can read it from other service – CPK_2011 May 22 '12 at 15:02
  • I'm confused. Do you want to display the XML to the user onscreen? – Yatrix May 22 '12 at 15:54
  • It is not for onscreen. But other service needs to consume this webservice in the form of xml. – CPK_2011 May 22 '12 at 16:20
  • Well, you said "display". See my edit. I think I know what you want, now. – Yatrix May 22 '12 at 17:25
  • Hi Yatrix, I just need to return XML from HelloWorld in proper format so that i can read it from other dataset in other WebService. The string xml cannot be read directly from dataset. – CPK_2011 May 23 '12 at 05:54