Find XmlNode where attribute value is contained in string

mikhga

New Member
I have an xml file...\[code\]<?xml version="1.0" encoding="UTF-8"?><items defaultNode="1"> <default contentPlaceholderName="pageContent" template="" genericContentItemName="" /> <item urlSearchPattern="connections-learning" contentPlaceholderName="pageContent" template="Connections Learning Content Page" genericContentItemName="" /> <item urlSearchPattern="online-high-school" contentPlaceholderName="pageContent" template="" genericContentItemName="" /></items>\[/code\]I am trying to find the first node where the urlSearchPattern attribute is contained in the string \[code\]urlSearchPattern\[/code\]. Where I'm having trouble is finding the nodes where the attribute is contained in the string value instead of the string value be contained in the attribute.Here's my attempt so far. This will find the firstOrDefault node where the string value is contained in the attribute (I need the opposite)...\[code\]string urlSearchPattern = Request.QueryString["aspxerrorpath"];MissingPageSettingsXmlDocument missingPageSettingsXmlDocument = new MissingPageSettingsXmlDocument();XmlNode missingPageItem = missingPageSettingsXmlDocument.SelectNodes(ITEM_XML_PATH).Cast<XmlNode>().Where(item => item.Attributes["urlSearchPattern"].ToString().ToLower().Contains(urlSearchPattern)).FirstOrDefault();\[/code\]
 
Back
Top