HI, This is an old question, i have seen some solutions on this forum itself, but am trying to use webservices for the first time so please bear with me on this one.
I have a webservice that returns XML in the following format
<subs xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" msisdn="965xxxxxx">
<shortcode label="XXXX">
<channels>
<channel>
<id>442</id>
<name>News</name>
<billingperiod>7</billingperiod>
<billingamount>3</billingamount>
<lastbilling>4/14/2010 1:41:11 PM</lastbilling>
</channel>
<channel>
<id>443</id>
<name>News2</name>
<billingperiod>7</billingperiod>
<billingamount>3</billingamount>
<lastbilling>4/14/2010 1:41:19 PM</lastbilling>
</channel>
</channels>
</shortcode>
</subs>
I want the same XMl output without the xmlns:xsd and xmlns:xsi tags.
I have tried the following solution that was suggested:
<WebMethod(MessageName:="GetSubscription")>
Public Function GetSubscription(....) As String
Dim namespaces As New XmlSerializerNamespaces
namespaces.Add(String.Empty, String.Empty)
Dim serializer As New XmlSerializer(SubsDetail.GetType)
Dim sw As New System.IO.StringWriter
Dim writer As New System.Xml.XmlTextWriter(sw)
writer.Formatting = Formatting.None
serializer.Serialize(writer, SubsDetail, namespaces)
writer.Close()
Return sw.toString()
The result was that I got an xml in the following format:
<string>
<?xml version="1.0" encoding="utf-16"?><subs msisdn="965xxxx">
<shortcode label="XXXX">
<channels>
<channel>
<id>442</id>
<name>News</name>
<billingperiod>7</billingperiod>
<billingamount>3</billingamount>
<lastbilling>4/14/2010 1:41:11 PM</lastbilling>
</channel>
<channel>
<id>443</id>
<name>News2</name>
<billingperiod>7</billingperiod>
<billingamount>3</billingamount>
<lastbilling>4/14/2010 1:41:19 PM</lastbilling>
</channel>
</channels>
</shortcode>
</subs>
</string>
Though the format of the xml is correct it is coming as string within the <string>
tags. This is really driving me nuts.
Can I get the output as xml without the outer string tags?