in the last days i tried to change a value of a single attribute of this application File
The Xml-File:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
xmlns:asmv2="urn:schemas-microsoft-com:asm.v2">
<assemblyIdentity name="Nameexample" version="2.3.4.5" publicKeyToken="=0123456789" language="neutral" processorArchitecture="x86" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="PublisherExample" asmv2:product="Productexample" asmv2:supportUrl="SupportExample" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" mapFileExtensions="true" minimumRequiredVersion="2.3.4.5" trustURLParameters="true">
<subscription>
<update>
<beforeApplicationStartup />
</update>
</subscription>
<deploymentProvider codebase="http://Test" />
</deployment>
</asmv1:assembly>
Here i try to change the value of
<description asmv2:product = "Productexample">
into
<description asmv2:product = "Productexample2">
,and the value of
<deploymentProvider codebase="http://Test" />
into
<deploymentProvider codebase="http://Test2" />
Currently i tried :
private void changeAttribute (string xmlPath)
{
string newValue = "Productexample2";
XmlDocument xmlDoc= new XmlDocument();
xmlDoc.Load(xmlPath);
XmlNode node = xmlDoc.SelectSingleNode("asmv1:assembly/description/asmv2:product");
node.Attributes[0].Value = newValue;
xmlDoc.Save(xmlPath);
}
But it throws the Exception 'An unhandled exception of type 'System.Xml.XPath.XPathException' occurred in System.Xml.dll' so i think asmv1:assembly/description/asmv2:product
is wrong ...
any suggestions of code?
as always you can correct me in any way :)
No comments:
Post a Comment