I have the following code snipet:
...
_xmldocManifest.Load(strManifestAbsolutePath)
Dim manifestNSManager As XmlNamespaceManager = New
XmlNamespaceManager(_xmldocManifest.NameTable)
manifestNSManager.AddNamespace(String.Empty,
"http://www.imsproject.org/xsd/imscp_rootv1p1p2")
manifestNSManager.AddNamespace("ns",
"http://www.imsproject.org/xsd/imscp_rootv1p1p2")
manifestNSManager.AddNamespace("adlcp",
"http://www.adlnet.org/xsd/adlcp_rootv1p2")
manifestNSManager.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
manifestNSManager.AddNamespace("xsi",
"http://www.w3.org/2001/XMLSchema-instance")
manifestNSManager.AddNamespace("schemaLocation",
"http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd
http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd
http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd")
manifestNSManager.PushScope()
However the following statement returns nothing (for the XML below):
_xmldocManifest.SelectSingleNode("//metadata", manifestNSManager)
But if I remove the first attribute of the manifest node
(xmlns=http://www.imsproject.org/xsd/imscp_rootv1p1p2) it works fine and I
can navigate the xml document with no problems. Any thoughts?
Note the following state works fine without removing the attribute:
_xmldocManifest.SelectSingleNode("//adlcp:location", manifestNSManager)
XML SNIPET:
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns="http://www.imsproject.org/xsd/imscp_rootv1p1p2"
xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_rootv1p2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsproject.org/xsd/imscp_rootv1p1p2
imscp_rootv1p1p2.xsd http://www.adlnet.org/xsd/adlcp_rootv1p2
adlcp_rootv1p2.xsd"
identifier="x-ims-plirid-v0.DUNS.05-107-9929.mfstid.en_US_11953">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
<adlcp:location>en_US_11953/en_US_11953.xml</adlcp:location>
</metadata>
</manifest>
Bjoern Hoehrmann - 23 Mar 2007 00:29 GMT
* need2scuba wrote in microsoft.public.dotnet.xml:
>I have the following code snipet:
>
[quoted text clipped - 5 lines]
>manifestNSManager.AddNamespace(String.Empty,
>"http://www.imsproject.org/xsd/imscp_rootv1p1p2")
This does not work the way you think it would.
>manifestNSManager.AddNamespace("ns",
>"http://www.imsproject.org/xsd/imscp_rootv1p1p2")
>_xmldocManifest.SelectSingleNode("//metadata", manifestNSManager)
Use
_xmldocManifest.SelectSingleNode("//ns:metadata", manifestNSManager)
instead.

Signature
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
WenYuan Wang - 26 Mar 2007 10:34 GMT
Hi,
>manifestNSManager.AddNamespace(String.Empty,
"http://www.imsproject.org/xsd/imscp_rootv1p1p2")
This statement means the default namespace for manifestNSManager is
"http://www.imsproject.org/xsd/imscp_rootv1p1p2".
>_xmldocManifest.SelectSingleNode("//metadata", manifestNSManager)
If the XPath expression does not include a prefix, it is assumed that the
namespace URI is the empty namespace. (xlmns="") Otherwise, if your XML
includes a default namespace, you must add a prefix and namespace URI to
it; otherwise, you will not get a selected node.
As Bjoern said, you can use
_xmldocManifest.SelectSingleNode("//ns:metadata", manifestNSManager)
instead.
Hope this helps. Please feel free to reply here if you have anything
unclear. I'm glad to assist you.
Have a great day,
Sincerely,
Wen Yuan
WenYuan Wang - 28 Mar 2007 09:28 GMT
Hello,
Have you resolved the issue now?
If it still persists or you have anything unclear, please don't hesitate to
update here. I'm glad to assis you.
Have a great day,
Sincerely,
Wen Yuan