A
adam
I tried so many ways to select the node but its not working, please help.
I want to research by the identifier in imsmanifest.xml file, the node could
be item or resource.
XmlDocument doc = new XmlDocument();
try
{
string node = Request.QueryString["node"]; //getting nodeid from
query string
doc.Load(Session["xmlFile"].ToString()); //load xml file from
session variable
//Create an XmlNamespaceManager for resolving namespaces.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
//there are two namespaces not sure if I am doing it correctly
nsmgr.AddNamespace("imscp",
"urn:http://www.imsglobal.org/xsd/imscp_v1p1");
nsmgr.AddNamespace("imsmd",
"urn:http://www.imsglobal.org/xsd/imsmd_v1p2");
XmlNodeList nodes = doc.SelectNodes(//@identifier);
*******works***********
***************but SelectSingleNode() doesn't work**************************
----------------------------------------------------------------------------------------------------------------
XmlNode selectednode =
doc.DocumentElement.SelectSingleNode("manifest/organizations/organization/it
em[@identifier='+node+']", nsmgr);
-----------------------------------------------------------------------------------------------------------------
}
catch (Exception ex)
{
this.txtTitle.Text = ex.Message.ToString();
}
-----------------------------------------------imsmanifest.xml
file----------------------------------------
<?xml version="1.0"?>
<manifest identifier="MANIFEST01"
xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"
xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1p3.xsd
http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
<metadata>
<schema>IMS CONTENT</schema>
<schemaversion>1.1</schemaversion>
<imsmd:lom>
<imsmd:general>
<imsmd:title>
<imsmd:langstring xml:lang="en">Auditing 1 [AU1]</imsmd:langstring>
</imsmd:title>
</imsmd:general>
</imsmd:lom>
</metadata>
<organizations default="MANIFEST01_ORG1">
<organization identifier="MANIFEST01_ORG1">
<item identifier="MANIFEST01_ITEM3" isvisible="1" parameters=""
identifierref="MANIFEST01_RESOURCE1">
<title>Module 1: Introduction to auditing</title>
<item identifier="MANIFEST01_ITEM13"
identifierref="MANIFEST01_RESOURCE3" isvisible="1" parameters="">
<title>1.1 Nature of auditing</title>
</item>
<item identifier="MANIFEST01_ITEM14"
identifierref="MANIFEST01_RESOURCE6" isvisible="1" parameters="">
<title>1.2 External and internal auditing</title>
</item>
<item identifier="MANIFEST01_ITEM15"
identifierref="MANIFEST01_RESOURCE9" isvisible="1" parameters="">
<title>1.3 Assurance engagements</title>
</item>
</item>
</organization>
</organizations>
<resources>
<resource identifier="MANIFEST01_RESOURCE1" type="webcontent"
href="module01\mod01.overview.htm">
<file href="module01\mod01.overview.htm"/>
</resource>
<resource identifier="MANIFEST01_RESOURCE2" type="webcontent"
href="module01\topic01\lo1.01.htm">
<file href="module01\topic01\lo1.01.htm"/>
</resource>
<resource identifier="MANIFEST01_RESOURCE3" type="webcontent"
href="module01\topic01\mod01.1.htm">
<file href="module01\topic01\mod01.1.htm"/>
</resource>
</resources>
I want to research by the identifier in imsmanifest.xml file, the node could
be item or resource.
XmlDocument doc = new XmlDocument();
try
{
string node = Request.QueryString["node"]; //getting nodeid from
query string
doc.Load(Session["xmlFile"].ToString()); //load xml file from
session variable
//Create an XmlNamespaceManager for resolving namespaces.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
//there are two namespaces not sure if I am doing it correctly
nsmgr.AddNamespace("imscp",
"urn:http://www.imsglobal.org/xsd/imscp_v1p1");
nsmgr.AddNamespace("imsmd",
"urn:http://www.imsglobal.org/xsd/imsmd_v1p2");
XmlNodeList nodes = doc.SelectNodes(//@identifier);
*******works***********
***************but SelectSingleNode() doesn't work**************************
----------------------------------------------------------------------------------------------------------------
XmlNode selectednode =
doc.DocumentElement.SelectSingleNode("manifest/organizations/organization/it
em[@identifier='+node+']", nsmgr);
-----------------------------------------------------------------------------------------------------------------
}
catch (Exception ex)
{
this.txtTitle.Text = ex.Message.ToString();
}
-----------------------------------------------imsmanifest.xml
file----------------------------------------
<?xml version="1.0"?>
<manifest identifier="MANIFEST01"
xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"
xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.imsglobal.org/xsd/imscp_v1p1 imscp_v1p1p3.xsd
http://www.imsglobal.org/xsd/imsmd_v1p2 imsmd_v1p2p2.xsd">
<metadata>
<schema>IMS CONTENT</schema>
<schemaversion>1.1</schemaversion>
<imsmd:lom>
<imsmd:general>
<imsmd:title>
<imsmd:langstring xml:lang="en">Auditing 1 [AU1]</imsmd:langstring>
</imsmd:title>
</imsmd:general>
</imsmd:lom>
</metadata>
<organizations default="MANIFEST01_ORG1">
<organization identifier="MANIFEST01_ORG1">
<item identifier="MANIFEST01_ITEM3" isvisible="1" parameters=""
identifierref="MANIFEST01_RESOURCE1">
<title>Module 1: Introduction to auditing</title>
<item identifier="MANIFEST01_ITEM13"
identifierref="MANIFEST01_RESOURCE3" isvisible="1" parameters="">
<title>1.1 Nature of auditing</title>
</item>
<item identifier="MANIFEST01_ITEM14"
identifierref="MANIFEST01_RESOURCE6" isvisible="1" parameters="">
<title>1.2 External and internal auditing</title>
</item>
<item identifier="MANIFEST01_ITEM15"
identifierref="MANIFEST01_RESOURCE9" isvisible="1" parameters="">
<title>1.3 Assurance engagements</title>
</item>
</item>
</organization>
</organizations>
<resources>
<resource identifier="MANIFEST01_RESOURCE1" type="webcontent"
href="module01\mod01.overview.htm">
<file href="module01\mod01.overview.htm"/>
</resource>
<resource identifier="MANIFEST01_RESOURCE2" type="webcontent"
href="module01\topic01\lo1.01.htm">
<file href="module01\topic01\lo1.01.htm"/>
</resource>
<resource identifier="MANIFEST01_RESOURCE3" type="webcontent"
href="module01\topic01\mod01.1.htm">
<file href="module01\topic01\mod01.1.htm"/>
</resource>
</resources>