-3
if(Node.NodeType.ToString().Equals("Element", StringComparison.InvariantCultureIgnoreCase))
{
    if(Node.Name.ToString().Equals("DeployWebsite", StringComparison.InvariantCultureIgnoreCase))
    {
        Count++;
    }
    string myString = Count.ToString();
    string name = "//"+"website"+"["+ myString+"]"+"/";

    string[] DetailsOfNodesToDisplay = Node.InnerText.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);

    for(int i = 0; i < DetailsOfNodesToDisplay.Count(); i++)
    {
        string addressOfNode = DetailsOfNodesToDisplay[i].Replace('.', '/');
        if(Node.Name.ToString().Equals("DeployWebsite", StringComparison.InvariantCultureIgnoreCase))
        {
            addressOfNode = addressOfNode.Replace("/Website/", "name");
            // string addressOfNode1 = addressOfNode.Replace("/website/", "//website[1]/");
        }
    }
}

I want to replace "/Website" with the value of name variable. Name variable is string containing value.

Rafalon
  • 4,450
  • 2
  • 16
  • 30
Mitali Patil
  • 67
  • 1
  • 9

1 Answers1

0

If you create the string on runtime use string interpolation like

string someString = "someText/{name}"; Where "/{name}" was "/Website" before.

but if the string is already defined use

someString.Replace("/Website", name);
lukger
  • 404
  • 3
  • 11