XSD to XML. Multiple namepaces without prefixes. How to?

mikeydavies

New Member
I am using an XSD file to generate C# code through xsd.exe and serializing XML using the resulting code.The problem is that I must generate an XML file having a defaut/root xmlns namespace, and an element definining another "raw" namespace on this element (without prefix).Here is a light sample (not the whole XML), for illustration purposes :\[code\]<?xml version="1.0" encoding="utf-16"?><Request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://mynamespace"> <ABC>STACKOVERFLOW</ABC> <Method Name="TEST" xmlns="http://myothernamespace"> <DEF>123456</DEF> </Method> </Request>\[/code\]I can't find a way to "insert" the second xmlns attribute as such on the Method element (without prefix).Thing is that I cannot use prefix, as this XML is sent to an application that is not using an XML deserializer on the other end, but which is parsing the XML as a string and looking for exact string match (and of course this is not possible to change this "receiving" application).I have tried a lot of different things in XSD but nothing works :( I am using MSMQ to transfer the XML message so I am not serializing the Request by myself (just giving correct parameters to the request object and the serialization is handled behind the scene).I could use an XmlSerializer to serialize the XML to a string without the second xmlns, and add it via coding to the XML (to the string) before sending it, but this is dirty and bugs me to go this way just to add this "xmlns" attribute on Method element.Is there any way to go arround this via pure XSD (through .NET code generation using xsd.exe) or not ?Hope my question is clear and hope some people will be able to answer itThanks in advance !
 
Back
Top