Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:19:43+00:00 2026-06-04T17:19:43+00:00

I want to be able to do something like this : //buildArgs XmlNode buildArgs

  • 0

I want to be able to do something like this :

 //buildArgs
 XmlNode buildArgs = doc.CreateElement("buildArgs");
 XmlAttribute buildArgsAtt = doc.CreateAttribute("-D:project.rc_file");

But I get the fallowing error :

An unhandled exception of type 'System.ArgumentException' occurred in System.Xml.dll

Additional information: Invalid name character in '-D'. The '-' character, hexadecimal value 0x2D, cannot be included in a name.

But I did not choose the format. I am trying to automate the process of adding a new element to cruisecontrol.net config file (ccnet.config). So I need to put that dash there.

This is my code :

   //create new instance of XmlDocument
        XmlDocument doc = new XmlDocument();
        doc.PreserveWhitespace = false;

        //load from file
        doc.Load(filename);

        //create node and add value
        XmlNode projet = doc.CreateNode(XmlNodeType.Element, "projet", null);
        XmlAttribute projetAtt = doc.CreateAttribute("name");
        projetAtt.Value = projectName + " " + oracleVersion;
        projet.Attributes.SetNamedItem(projetAtt);

        ...

        //buildArgs
        XmlNode buildArgs = doc.CreateElement("buildArgs");
        XmlAttribute buildArgsAtt = doc.CreateAttribute("-D:project.rc_file");
        buildArgsAtt.Value = projectName + ".rc";
        XmlAttribute buildArgsAtt2 = doc.CreateAttribute("-D:project.svn_trunk_ver");
        buildArgsAtt2.Value = trunkNb;
        XmlAttribute buildArgsAtt3 = doc.CreateAttribute("-D:project.svn_trunk");
        buildArgsAtt3.Value = trunkPath;
        buildArgs.Attributes.SetNamedItem(buildArgsAtt);
        buildArgs.Attributes.SetNamedItem(buildArgsAtt2);
        buildArgs.Attributes.SetNamedItem(buildArgsAtt3);

        //add to parent node
        projet.AppendChild(nodeWD);
        projet.AppendChild(category);
        projet.AppendChild(trigger);
        trigger.AppendChild(intTrigger);
        projet.AppendChild(sourcecontrol);
        sourcecontrol.AppendChild(trunkUrl);
        sourcecontrol.AppendChild(workingDirectory);
        projet.AppendChild(tasks);
        tasks.AppendChild(nant);
        nant.AppendChild(targetList);
        targetList.AppendChild(target);
        nant.AppendChild(buildArgs);

        //add to elements collection
        doc.DocumentElement.AppendChild(projet);

        XmlWriterSettings settings = new XmlWriterSettings();
        settings.Indent = true;
        settings.NewLineOnAttributes = true;
        settings.Encoding = Encoding.UTF8;

        using (XmlWriter writer = XmlTextWriter.Create(filename, settings))
        {
            doc.Save(writer);
        }

I checked this : Using – in XML element name and others, but I didn’t find an answer that I could use.

-EDIT-

This is an exemple of the ccnet.config :
http://ccnet.sourceforge.net/CCNET/Configuring%20the%20Server.html

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:19:44+00:00Added an answer on June 4, 2026 at 5:19 pm

    Which line of the example config? Do you mean this one?

    <buildArgs>-D:cvs.executable=c:\putty\cvswithplinkrsh.bat</buildArgs>
    

    That’s not an attribute. It’s element content.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want something like a canvas, but where i'd be able to manipulate pixels
I want to be able to do something like this <test:TabControl id= runat=server....> <ItemTemplate>
I want to be able to do something like this SELECT `first_name` + +
I want to be able to do something like this in a stateless Session
I want to be able to do something like this: function x(){ ....blablabla.. return
I want to be able to do something like this: <uc:MyUC> <CustomContent> <span id=name>johnny
I want to be able to declare something like this: trait Narrowable[A] extends Iterable[A]
I want to be able to do something like this: $table_object->getRows()->where($wer)->or($or)->orderBy('field', 'DESC'); If i
I want to be able to do something like this: if (Is_Function(helloworld) // Run
I want to be able to do something like this: var MyObject = function(prop)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.