各位:我想用Javascript查询XML里面的数据,根据几个条件来进行组合查询,如查询某个时间时间段之内标题TITLE包含JACK的单词.
xmlReportData.setProperty('SelectionLanguage','XPath');
var node = xmlReportData.documentElement.selectNodes("//root/document[contains(title,'JACK')>0 and doc_date>='" + id +"' and doc_date<='" + id1 +"']"); 这样查询总是查不到数据
如果如下这样单独查询就没有问题
1) xmlReportData.setProperty('SelectionLanguage','XPath');
var node = xmlReportData.documentElement.selectNodes("//root/document[contains(title,'JACK')]");
2)
var node = xmlReportData.documentElement.selectNodes("//root/document[doc_date>='" + id +"' and doc_date<='" + id1 +"']");
不知道是何故?谁能帮我解答一下?
xmlReportData.setProperty('SelectionLanguage','XPath');
var node = xmlReportData.documentElement.selectNodes("//root/document[contains(title,'JACK')>0 and doc_date>='" + id +"' and doc_date<='" + id1 +"']"); 这样查询总是查不到数据
如果如下这样单独查询就没有问题
1) xmlReportData.setProperty('SelectionLanguage','XPath');
var node = xmlReportData.documentElement.selectNodes("//root/document[contains(title,'JACK')]");
2)
var node = xmlReportData.documentElement.selectNodes("//root/document[doc_date>='" + id +"' and doc_date<='" + id1 +"']");
不知道是何故?谁能帮我解答一下?
解决方案 »
- 关于jQuery验证手机号码的问题,为什么不起作用?请大家帮我看看,多谢!
- 求一个简单的特效
- 以下这段代码是什么意思 be.icast.cn是不是一个黑网站
- 用了一年多javascript遇到了最郁闷的一件事。在此把问题贴出来,让大家避免也为此事郁闷
- 在父窗口用window.open()方法,打开新页面后,父窗口能不能自动关闭,并且不用提示?
- 数组问题 急急急急急急急!!!!!!
- 可用分捐赠[2003-1-13=>2003-1-25] Total 5786
- 怎么用JAVASCRIPT关闭一个窗口的时个不提示那个对话框???
- JS里是否能得到客户机的屏幕分辨率?
- Javascript如何作错误处理?
- 这是javascript的那个分支
- 在这个正则基础之上加个Ip端口号
里面有详细的实现
<?xml version="1.0" ?>
<root>
<document id="1">
<cabinet>09. SWD</cabinet>
<folder>to HIPHING</folder>
<title>Reply to CVI</title>
<ref></ref>
<doc_type>GEN - General Issues</doc_type>
<doc_date>2009-05-25</doc_date>
<issue_ref></issue_ref>
<our_ref></our_ref>
<your_ref></your_ref>
<description></description>
<from_company>SWD</from_company>
<to_company>YEARFULL</to_company>
<our_ref_1></our_ref_1>
<your_ref_1></your_ref_1>
<submission_ref></submission_ref>
<attachment_links></attachment_links>
<status></status>
<keywords></keywords>
<confidential>No</confidential>
<created_by></created_by>
<created_on>2009-05-25 04:40:19 PM</created_on>
<system_no>PIMS/000300</system_no>
<version>1.0</version>
<doc_size>1.4 MB</doc_size>
<doc_extension>pdf</doc_extension>
<path>09. SWD/to HIPHING</path>
<file_name>SKMBT_C55009052516300.pdf</file_name>
</document></root>
var loadXML = function(xmlFile)
{
var xmlDoc;
if(window.ActiveXObject)
{
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = false;
xmlDoc.load(xmlFile);
}
else if (document.implementation&&document.implementation.createDocument)
{
xmlDoc = document.implementation.createDocument('', '', null);
xmlDoc.load(xmlFile);
}
else
{
return null;
}
return xmlDoc;
}var initializeSelect = function(xPath)
{
var xmlDoc = loadXML('/EBS/XML/Login.xml');
var n;
var l;
if(e!=null)
{
n = xmlDoc.getElementsByTagName(xPath);
alert(n[0].childNodes);//操作node节点
}
}
我看了这几偏文章,但还是不明白,因为没有对日期的操作比较,是不是XPATH,对日期格式不支持还是什么原因?
另外这个列子好象还不能下载,所以也就无法看到运行的结果!