Новости | FAQ | Авторы | Документация | В действии | Библиотека |
Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Александр Петросян (PAF) 04.11.2003 10:19 / 04.11.2003 10:22
а объявили с namespace, закономерно не находит.However, if the same XML document is namespace qualified that is by updating the following line in the original XML files:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk30/htm/xmconhowtospecifynamespaceinxpathexpressions.asp
<?xml version="1.0" encoding="utf-8" ?>
<myDoc xmlns="urn:myDoc">
<greeting>Hello World!</greeting>
<greeter>
<first-name>John</first-name>
<last-name>Doe</last-name>
</greeter>
</myDoc>
you must then set the SelectionNamespaces property on the DOM object prior to making your XPath selection. For example, update the previous JScript to insert the following line of code as the new first statement within the body of the else statement:
d.setProperty("SelectionNamespaces", "xmlns:a='urn:myDoc'");
Next you need to adjust your XPath expression so that it uses QNames (fully namespace qualified names) instead of unqualified names in order to achieve the same results and output as "Hello World!" which uses the modified sample XML document.
For example, to retrieve the <a:greeting> element, in the previous JScript code, you now need to have the XPath expression updated to read as follows:
var node = d.selectSingleNode("/a:myDoc/a:greeting");