I have a method below that returns List of xelements.
public static List<XElement> GetSites() { List<XElement> returnElemnt = new List<XElement>(); if (Settings != null) { //Returns List<Xelement> returnElemnt = GetAllSites(WSQueryText); } return returnElemnt; } From the returned List. I also want to check if this XML contains certain attributes. If it does, then I want to set certain conditions based on the attributes as mentioned in the code below.
XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(@"test.xml"); XmlNamespaceManager nsmngr = new XmlNamespaceManager(xmlDoc.NameTable); nsmngr.AddNamespace("srch", "urn:Microsoft.Search.Response"); nsmngr.AddNamespace("doc", "urn:Microsoft.Search.Response.Document"); foreach (XmlNode site in xmlDoc.SelectNodes("//srch:Response/srch:Range/srch:Results/doc:Document", nsmngr)) { bool hasAccess = HasAccess(site, "OWNER", nsmngr, accessIds); if (!hasAccess) { XmlAttribute attr = xmlDoc.CreateAttribute("Locked"); attr.Value = "true"; site.Attributes.Append(attr); } } resultXml = xmlDoc.OuterXml; How can I check this against the list of xElements within the same method?
No comments:
Post a Comment