w3 학교의 예제를 따라 xpath를 사용하여 my xml 문서를 탐색했지만 iterateNext()는 null입니다. 아래는 내 blog.xml 파일입니다.document.evaluate는 iterateNext로 null을 반환합니다.
<blog
xmlns ="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="blogschema.xsd">
<Title>My blog</Title>
<Entry>
<Heading id="101">week1</Heading>
<body>
<text>enter text right here</text>
<pictures>pictures in the body</pictures>
</body>
<labels>Seperate labels with commas</labels>
<date> 20121119</date>
</Entry>
</blog>
결과는 항상 null을 반환 이것은, while 문이 내려다 보이는 메신저이 아마도 뭔가를 내 HTML 스크립트 도달하지 않습니다,하지만 난 그것을 W3 학교에 있었다면 정말 일을해야한다고 생각했습니다.
xmlDoc=loadXMLDoc("blog.xml");//loads xml file
//loadXmlContent(xmlDoc); using xml dom
path="/blog/Title"
if(document.implementation && document.implementation.createDocument)
{
var nodes = xmlDoc.evaluate(path, xmlDoc, null, 5, null);
alert(nodes);
var result = nodes.iterateNext();
while (result)
{document.write(result.childNodes[0].nodeValue);}
}
</script>
(https://developer.mozilla.org/en-US/docs/Introduction_to_using_XPath_in_JavaScript) [W3 스쿨] 이상 (http://w3fools.com/). – jbabey