S
S
Sergey Karbivnichy2016-02-07 17:21:40
Programming
Sergey Karbivnichy, 2016-02-07 17:21:40

How to write in c# in xml xmlns?

Here is the code:

XmlWriterSettings xsettings = new XmlWriterSettings();
        xsettings.Indent = true;

        XmlWriter xmlWriter = XmlWriter.Create("/home/guest/Desktop/users.csproj",xsettings);
        xmlWriter.WriteStartDocument();
        xmlWriter.WriteStartElement("Project");

        xmlWriter.WriteAttributeString("ToolsVersion","4.0");
        xmlWriter.WriteAttributeString("DefaultTargets","Build");
        xmlWriter.WriteAttributeString("xmlns","http://schemas.microsoft.com/developer/msbuild/2003");

Но при записи появляется ошибка - "System.Xml.XmlException: The prefix '' cannot be redefined from '' to 'schemas.microsoft.com/developer/msbuild/2003' within the same start element tag."
Находил примеры с использованием префиксов - примеры то работают, но мне они не подходят, так как мне нужно записать именно:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Петр, 2016-02-07
@hottabxp

An example is here
And here how to add a few.
You don't have a namespace

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question