Signing an XML

public void sign(){XmlDocument doc = new XmlDocument();doc.Load(@"C:\Inetpub\wwwroot\NumberVerfication\NumberVerification.xml"); SignedXml signer = new SignedXml(doc);RSA key = new RSACryptoServiceProvider();signer.KeyInfo = new KeyInfo();signer.KeyInfo.AddClause(new RSAKeyValue(key));signer.SigningKey = key;Reference orderRef = new Reference("");orderRef.AddTransform(new XmlDsigEnvelopedSignatureTransform());signer.AddReference(orderRef);signer.ComputeSignature();doc.DocumentElement.AppendChild(signer.GetXml());txtOutput.Text = doc.InnerText;doc.Save(@"E:\Numberverification.xml");}This method will give the signed XML. This uses RSA Crtytography Algorithm.


Reading Data from XML

public string GetElementValue(string strElementName){reader = new XmlTextReader(@"C:\Inetpub\wwwroot\NumberVerfication\NumberVerification.xml");Boolean flag = false;string strElementValue = String.Empty;while (reader.Read()){if (reader.LocalName == strElementName){reader.Read();strElementValue = reader.Value;reader.Read();flag = true;}}if (flag == false){return null;}elsereturn strElementValue;}Here i/p for themethod strElementName is the tag name in the xml for which the value has to be read.

Getting value from a XML file of a SPList item

public string GeUserAttributeValue(SPList listCollection, string attributeName,string userName){if (userName == null){userName = this.web.CurrentUser.Name;}for (int count = 0; count }break; } } return strDeptName; } "z", "#RowsetSchema is the namespace used in the XML and hence we add it to the namespace manager.ows_Department is the name of field in XML for the Department field in the list.

Create a website or blog at

Up ↑

%d bloggers like this: