I have a sample XML where I request nodes based on a date.
Example XML document :
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>
<NewDataSet>
<Table>
<EmployeeBankGUID>dc396ebe-c8a4-4a7f-85b5-b43c1890d6bc</EmployeeBankGUID>
<ValidFromDate>2012-02-01T00:00:00-05:00</ValidFromDate>
</Table>
<Table>
<EmployeeBankGUID>2406a5aa-0246-4cd7-bba5-bb17a993042b</EmployeeBankGUID>
<ValidFromDate>2013-02-01T00:00:00-05:00</ValidFromDate>
</Table>
<Table>
<EmployeeBankGUID>2af49699-579e-4beb-9ab0-a58b4bee3158</EmployeeBankGUID>
<ValidFromDate>2014-02-01T00:00:00-05:00</ValidFromDate>
</Table>
</NewDataSet>
So basically three dates:
Using MSXML, I can query and filter these dates using an XPath query:
/NewDataSet/Table[ValidFromDate>"2013-02-12"]
And this works and returns IXMLDOMNodeListcontaining one element:
<Table>
<EmployeeBankGUID>2af49699-579e-4beb-9ab0-a58b4bee3158</EmployeeBankGUID>
<ValidFromDate>2014-02-01T00:00:00-05:00</ValidFromDate>
</Table>
Except it no longer works
This XPath query using MSXML; an xml variant created by Microsoft in the late 1990s before W3C was standardized on a completely different form of XPath.
DOMDocument doc = new DOMDocument();
IXMLDOMNodeList nodes = doc.selectNodes('/NewDataSet/Table[ValidFromDate>"2013-02-12"]');
MSXML ( ). 2005 , , , , , , MSXML 6.
, DOMDocument60, DOMDocument:
DOMDocument doc = new DOMDocument60();
IXMLDOMNodeList nodes = doc.selectNodes('/NewDataSet/Table[ValidFromDate>"2013-02-12"]');
XPath .
" " ?
, ,
, , , XML 2013-02-01T00:00:00-05:00 , . , , , .
, , . :
/NewDataSet/Table[ValidFromDate<"a"]/NewDataSet/Table[ValidFromDate>"a"]/NewDataSet/Table[ValidFromDate!="a"] /NewDataSet/Table[ValidFromDate>"2014-02-12T00:00:00-05:00"]/NewDataSet/Table[ValidFromDate<"2014-02-12T00:00:00-05:00"]/NewDataSet/Table[ValidFromDate!="2014-02-12T00:00:00-05:00"]
,
, , , ?
"" XPath ?
, , XPath ?
, , , , ? , , . , , "" ?
MSXML6
, , :
DOMDocument60 GetXml(String url)
{
XmlHttpRequest xml = CoServerXMLHTTP60.Create();
xml.Open('GET', url, False, '', '');
xml.Send(EmptyParam);
DOMDocument60 doc = xml.responseXML AS DOMDocument60;
doc.setProperty('SelectionNamespaces', 'xmlns:ms="urn:schemas-microsoft-com:xslt"');
return doc;
}
DOMDocument doc = GetXml('http://example.com/GetBanks.ashx?employeeID=12345');
String qry = '/NewDataSet/Table[ms:string-compare(ValidFromDate, "2014-02-12") >= 0]';
IXMLDOMNodeList nodes = doc.selectNodes(qry);