c# - How To remove xmlns tag -
i have code below.
namespace irancellsmsserver { [webservice(namespace = "http://www.csapi.org/schema/parlayx/data/sync/v1_0/local")] public class soapserver : system.web.services.webservice { [soapdocumentmethod(action = "",parameterstyle = soapparameterstyle.bare)] [webmethod] public syncorderrelationresponse syncorderrelation( sync.userid userid, string spid, string productid, string serviceid, string servicelist, int updatetype, string updatetime, string updatedesc, string effectivetime, string expirytime, item[] extensioninfo ) { syncorderrelationresponse = new syncorderrelationresponse(); a.result = 0; a.resultdescription = "ok"; return a; }
which generates me :
<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <userid xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local"> <id xmlns="">string</id> <type xmlns="">int</type> </userid> <spid xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</spid> <productid xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</productid> <serviceid xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</serviceid> <servicelist xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</servicelist> <updatetype xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">int</updatetype> <updatetime xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</updatetime> <updatedesc xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</updatedesc> <effectivetime xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</effectivetime> <expirytime xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local">string</expirytime> <extensioninfo xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local"> <item> <key xmlns="">string</key> <value xmlns="">string</value> </item> <item> <key xmlns="">string</key> <value xmlns="">string</value> </item> </extensioninfo> </soap:body> </soap:envelope>
i want xmlns="http://www.csapi.org/schema/parlayx/data/sync/v1_0/local
removed . ok before until added line
[soapdocumentmethod(action = "",parameterstyle = soapparameterstyle.bare)]
after added line started getting namespaces;
what want generate :
<?xml version="1.0" encoding="utf-8"?> <soap:envelope xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:body> <userid> <id xmlns="">string</id> <type xmlns="">int</type> </userid> <spid>string</spid> <productid>string</productid> <serviceid>string</serviceid> <servicelist>string</servicelist> <updatetype>int</updatetype> <updatetime>string</updatetime> <updatedesc>string</updatedesc> <effectivetime>string</effectivetime> <expirytime>string</expirytime> <extensioninfo> <item> <key xmlns="">string</key> <value xmlns="">string</value> </item> <item> <key xmlns="">string</key> <value xmlns="">string</value> </item> </extensioninfo> </soap:body> </soap:envelope>
what should . thanks.
check this answer , try recursive function:
//implemented based on interface, not part of algorithm public static string removeallnamespaces(string xmldocument) { xelement xmldocumentwithoutns = removeallnamespaces(xelement.parse(xmldocument)); return xmldocumentwithoutns.tostring(); } //core recursion function private static xelement removeallnamespaces(xelement xmldocument) { if (!xmldocument.haselements) { xelement xelement = new xelement(xmldocument.name.localname); xelement.value = xmldocument.value; foreach (xattribute attribute in xmldocument.attributes()) xelement.add(attribute); return xelement; } return new xelement(xmldocument.name.localname, xmldocument.elements().select(el => removeallnamespaces(el))); }
Comments
Post a Comment