EDN Admin
Well-known member
Hi,
I want to get an node value which matches a specified attribute value.
Below is my code...
XElement xe = XElement.Load(strPath + "\LogsTimeFormats.xml");
Func<XElement, bool> whereClause;
if (strFileName.Contains("*.*"))
{
whereClause = a => a.ToString().IndexOf(strFileName.Substring(0, a.ToString().Length - 4)) > -1;
}
var query = xe.Descendants("File").Where(whereClause).Select(a => a.Value);
The above code does not work, throws exception on the line, whereclause =...."
The strFileName value that is passes is messages*.*
XMl file is
<?xml version="1.0" encoding="utf-8" ?>
<LogFiles>
<File name="messages <![CDATA[MMM d HH:mm:ss]]></File>
<File name="fusionserver*.* <![CDATA[MMM d, yyyy h:mm:ss tt]]></File>
</LogFiles>
Can anyone help me o fix it?
View the full article
I want to get an node value which matches a specified attribute value.
Below is my code...
XElement xe = XElement.Load(strPath + "\LogsTimeFormats.xml");
Func<XElement, bool> whereClause;
if (strFileName.Contains("*.*"))
{
whereClause = a => a.ToString().IndexOf(strFileName.Substring(0, a.ToString().Length - 4)) > -1;
}
var query = xe.Descendants("File").Where(whereClause).Select(a => a.Value);
The above code does not work, throws exception on the line, whereclause =...."
The strFileName value that is passes is messages*.*
XMl file is
<?xml version="1.0" encoding="utf-8" ?>
<LogFiles>
<File name="messages <![CDATA[MMM d HH:mm:ss]]></File>
<File name="fusionserver*.* <![CDATA[MMM d, yyyy h:mm:ss tt]]></File>
</LogFiles>
Can anyone help me o fix it?
View the full article