我无法使用 linq to xml 修改 xml。这是我正在使用的代码:
在下面的代码中,Parameters[0] 的值为“payments”
XElement modMethodXElement = new XElement(xdoc1.XPathSelectElement("//INPUT[@VALUE='SLN7DEACTIVATION']/METHOD[@NAME='"+Parameters[0]+"']"));
modMethodXElement.SetAttributeValue("PARAMETERS", "ParameterValue");
这是我正在尝试修改的 xml 的一部分:
SESSIONANALYSER>
<AP>
<MODES>
<NI>
<STATEINFORMATION TYPE="PREPAID">
<INIT INVALIDINPUTRESPONSE="-2">
<INPUT VALUE="SLN7ACTIVATION">
<METHOD NAME="CHECKSUBSCRIBERBALANCE" PARAMETERS="SLN7" POSSIBLEACTIONS="FALLOUTON_FAILUREREGION_SETPSOFAILED_FALSE" MAINTAINSESSION="NO" RESPONSE="-4" NEXTLEVEL="" />
<METHOD NAME="SETPSOINUCIP" PARAMETERS="SLN7" POSSIBLEACTIONS="FALLOUTON_FAILUREREGION_SETPSOFAILED_FALSE" MAINTAINSESSION="NO" RESPONSE="-4" NEXTLEVEL="" />
<METHOD NAME="SENDMESSAGE" PARAMETERS="" POSSIBLEACTIONS="FALLOUTONSUCCESS" MAINTAINSESSION="NO" RESPONSE="0" NEXTLEVEL="" />
</INPUT>
<INPUT VALUE="SLN7DEACTIVATION">
<METHOD NAME="UNSETPSOINUCIP" PARAMETERS="SLN7" POSSIBLEACTIONS="FALLOUTON_FAILUREREGION_SETPSOFAILED_FALSE" MAINTAINSESSION="NO" RESPONSE="-4" NEXTLEVEL="" />
***<METHOD NAME="payments" PARAMETERS="fsdg" POSSIBLEACTIONS1="fg,f" MAINTAINSESSION="fdjfg89" RESPONSE="ndfgm" NEXTLEVEL="msdfm"></METHOD>***
<METHOD NAME="SENDMESSAGE" PARAMETERS="23" POSSIBLEACTIONS1="FALLOUTONSUCCESS" MAINTAINSESSION="yes" RESPONSE="format" NEXTLEVEL="msdfm"></METHOD>
<METHOD NAME="payments" PARAMETERS="12" POSSIBLEACTIONS1="FALLOUTONSUCCESS" MAINTAINSESSION="yes" RESPONSE="format" NEXTLEVEL="msvm"></METHOD>
<METHOD NAME="SENDMESSAGE" PARAMETERS="23" POSSIBLEACTIONS1="FALLOUTONSUCCESS" MAINTAINSESSION="yes" RESPONSE="0" NEXTLEVEL="3"></METHOD>
<METHOD NAME="SENDMESSAGE" PARAMETERS="23" POSSIBLEACTIONS1="FALLOUTONSUCCESS" MAINTAINSESSION="NO" RESPONSE="format" NEXTLEVEL="3"></METHOD>
</INPUT>
</INIT>