XML namespace position

mafiaen.dk

New Member
Can someone guide me how can I get namespaces in right positions. Currently I get following:\[code\]<agr:ABWInvoice xmlns:agr="http://services.agresso.com/schema/ABWInvoice/2011/11/14" xsi:schemaLocation="http://services.agresso.com/schema/ABWInvoice/2011/11/14 http://services.agresso.com/schema/ABWInvoice/2011/11/14/ABWInvoice.xsd" xmlns:agrlib="http://services.agresso.com/schema/ABWSchemaLib/2011/11/14" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >\[/code\]I want something like this:\[code\]<agr:ABWInvoice xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:agrlib="http://services.agresso.com/schema/ABWSchemaLib/2011/11/14" xmlns:agr="http://services.agresso.com/schema/ABWInvoice/2011/11/14" xsi:schemaLocation="http://services.agresso.com/schema/ABWInvoice/2011/11/14 http://services.agresso.com/schema/ABWInvoice/2011/11/14/ABWInvoice.xsd">\[/code\]I add namespaces like this:\[code\]XmlSerializerNamespaces ns = new XmlSerializerNamespaces();ns.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");ns.Add("agrlib", "http://services.agresso.com/schema/ABWSchemaLib/2011/11/14");ns.Add("agr", "http://services.agresso.com/schema/ABWInvoice/2011/11/14");\[/code\]Invoice look like this:\[code\] [Serializable] [XmlRootAttribute("ABWInvoice", Namespace = "http://services.agresso.com/schema/ABWInvoice/2011/11/14")] public class ABWInvoice { private List<Invoice> _invoice = new List<Invoice>(); [XmlAttributeAttribute("schemaLocation", AttributeName = "schemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")] public string SchemaLocation = "http://services.agresso.com/schema/ABWInvoice/2011/11/14 http://services.agresso.com/schema/ABWInvoice/2011/11/14/ABWInvoice.xsd"; [XmlElement("Invoice", Namespace = "http://services.agresso.com/schema/ABWInvoice/2011/11/14")] public List<Invoice> Invoices { get { return (_invoice); } set { _invoice = value; } } }\[/code\]
 
Back
Top