Question update: im very sorry if my question is not clear
here is the code im using right now
XDocument doc = XDocument.Parse(framedoc.ToString());
foreach (var node in doc.Descendants("document").ToList())
{
XNamespace ns = "xsi";
node.SetAttributeValue(ns + "schema", "");
node.Name = "alto";
}
and here is the output
<alto p1:schema="" xmlns:p1="xsi">
my goal is like this
xsi:schemaLocation=""
where does the p1
and xmlns:p1="xsi"
came from?
When you write
That's creating an
XNamespace
with a URI of just "xsi". That's not what you want. You want a namespace alias ofxsi
... with the appropriate URI via anxmlns
attribute. So you want:Or better, just set the alias at the root element:
Sample creating a document:
Output: