Home > Net >  C # how to replace string) specified in the XML file
C # how to replace string) specified in the XML file

Time:09-24

Open an XML file, want to put all files identified as $path $string substitution for a string variable path, the path variable is the string before the replacement, should how to replace, I ask you, thank you,

 
Path=myreg. GetValue (" SetupPath "). The ToString ();
XmlDocument doc=new XmlDocument ();
If (the File. The Exists (" a.x ml "))//
{
Doc. The Load (" a.x ml ");
Doc. Replace (" $$" path, the path).
Console. WriteLine (" the file has been modified!" );
}
The else
{
Console. WriteLine (" the file does not exist!" );
}
Doc. Save (" a.x ml ");
Console. WriteLine (" a.x ml successfully saved ");
  •  Tags:  
  • C #
  • Related