Generate xml attributes

VarenallNeamy

New Member
I have to create an xml file, that contains an element with attributes like:\[code\] <element xsi:schemaLocation="http://test.xsd" xmlns="http://test2" xmlns:xsi=http://test3>\[/code\]I tried:\[code\] XNamespace ns = "xsi"; var root = new XElement("element", new XAttribute(ns + "schemaLocation", "http://test.xsd"), // (I) new XAttribute(XNamespace.Xmlns, "http://test2"), // (II) new XAttribute(XNamespace.Xmlns + "xsi", "http://test3"), // (III)\[/code\]But the only thing that is generated fine is (III):\[code\] xmlns:xsi=http://test3\[/code\](I) is generated like:\[code\] p1:schemaLocation="http://test.xsd" xmlns:p1="xsi"\[/code\]and (II) is not generated because the line doesn't compile.Any idea on how I could generate these attributes?Thank you,LEDIT - also found it here: Creating XML with namespaces and schemas from an XElement
 
Back
Top