<?xml version="1.0" encoding="gb2312"?>
<manifest identifier="SingleSharableResource_MulitipleFileManifest" version="1.1" 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.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd
http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd">
<metadata/>
<organizations default="hooyes">
<organization identifier="hooyes">
<item xmlns="" identifier="B_hooyes">
<item xmlns="http://www.imsproject.org/xsd/imscp_rootv1p1p2" identifier="B_01_cnn1_1" isvisible="true">
<title>关于个人</title>
<item identifier="S_men" identifierref="R_S_men" isvisible="true">
<title>男人</title>
</item>
<item identifier="S_women" identifierref="R_S_women" isvisible="true">
<title>女人</title>
</item>
</item>
</item>
</organization>
</organizations>
<resources>
<resource identifier="R_S_men" type="webcontent" adlcp:scormtype="sco" href="unit1/index_content.html">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
<adlcp:location>unit1/index_content.html</adlcp:location>
</metadata>
<file href="unit1/index_content.html"/>
<dependency identifierref="R_D_01_Contentcnn1_1_1"/>
</resource>
<resource identifier="R_S_women" type="webcontent" adlcp:scormtype="sco" href="unit2/index_content.html">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
<adlcp:location>unit2/index_content.html</adlcp:location>
</metadata>
<file href="unit2/index_content.html"/>
<dependency identifierref="R_D_01_Contentcnn1_1_2"/>
</resource>
</resources>
</manifest>xml 的特征如上:
如今想通过方法 fx(xml)
想得到如下格式数据:序号 节点名称 url
1 关于个人 0
2 男人 unit1/index_content.html
3 女人 unit2/index_content.html
.....
高手能否给个实现例子.
<manifest identifier="SingleSharableResource_MulitipleFileManifest" version="1.1" 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.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd
http://www.adlnet.org/xsd/adlcp_rootv1p2 adlcp_rootv1p2.xsd">
<metadata/>
<organizations default="hooyes">
<organization identifier="hooyes">
<item xmlns="" identifier="B_hooyes">
<item xmlns="http://www.imsproject.org/xsd/imscp_rootv1p1p2" identifier="B_01_cnn1_1" isvisible="true">
<title>关于个人</title>
<item identifier="S_men" identifierref="R_S_men" isvisible="true">
<title>男人</title>
</item>
<item identifier="S_women" identifierref="R_S_women" isvisible="true">
<title>女人</title>
</item>
</item>
</item>
</organization>
</organizations>
<resources>
<resource identifier="R_S_men" type="webcontent" adlcp:scormtype="sco" href="unit1/index_content.html">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
<adlcp:location>unit1/index_content.html</adlcp:location>
</metadata>
<file href="unit1/index_content.html"/>
<dependency identifierref="R_D_01_Contentcnn1_1_1"/>
</resource>
<resource identifier="R_S_women" type="webcontent" adlcp:scormtype="sco" href="unit2/index_content.html">
<metadata>
<schema>ADL SCORM</schema>
<schemaversion>1.2</schemaversion>
<adlcp:location>unit2/index_content.html</adlcp:location>
</metadata>
<file href="unit2/index_content.html"/>
<dependency identifierref="R_D_01_Contentcnn1_1_2"/>
</resource>
</resources>
</manifest>xml 的特征如上:
如今想通过方法 fx(xml)
想得到如下格式数据:序号 节点名称 url
1 关于个人 0
2 男人 unit1/index_content.html
3 女人 unit2/index_content.html
.....
高手能否给个实现例子.
解决方案 »
- webbrowser控件 怎么模拟其他类型的浏览器访问网页?或者数据包的形式
- 请教一个关于获取上一篇标题和下一篇标题的思路问题
- 请问,谁知道我们学过C语言的怎么学习C#比较好点?
- 利用FileUpload控件,将图片传入数据库
- 当控件绑定了DataTable时,如何让DataTable的变更不触发事件?
- 如何定义一个 AgentObjects.IAgentCtlCharacterEx 数组
- GridView更新问题!
- [端午节]送大家一个使用TimeStamp控制数据库并发的例子
- 有段代码看不懂~ 求大神指点~~
- 有用过ldap的朋友近来看看
- ???向这里的高手请教ListView里的大图标间距设置问题 ???
- 第二次发送stat命令 返回值总是+ok 0 0 为什么???
dom.LoadXml(xml);
foreach (System.Xml.XmlNode node in dom.ChildNodes)
{
Response.Write(Get(node)+"<BR>");
}
string Get(System.Xml.XmlNode node)
{
string str = node.InnerText;
if (node.HasChildNodes)
{
str = "";
foreach (System.Xml.XmlNode n in node.ChildNodes)
{
str += Get(n);
}
}
return str;
}
用XMLDocument(存入内存中读取)
或XMLReader(只向前读取)
DataSet的Load方法处理有一定的局限性(文档树不能超过三层;根元素不能有属性;根元素不能超过一个,否则多余的根元素及子元素无效),不能处理复杂的结构
using System.Collections.Generic;
using System.Text;
using System.Xml;namespace TestConsoleApplication
{
class Program
{
static void Main(string[] args)
{
Test3 te = new Test3();
te.xmlTest();
Console.Read();
} class Test3
{
int i = 0;
XmlDocument myXml = new XmlDocument();
Xml xml = new Xml();
public void xmlTest()
{
myXml.Load("E:/test.xml");
XmlNodeList node = myXml.DocumentElement.ChildNodes;
XmlNode node2 = node.Item(1);
foreach (XmlNode var in node2.ChildNodes)
{
foreach (XmlNode var1 in var.ChildNodes)
{
foreach (XmlNode var2 in var1.FirstChild)
{
switch (var2.Name)
{
case "title":
xml.title = var2.InnerText;
break;
case "item":
xml.name[i] = var2.InnerText;
++i;
break;
default:
break;
}
}
}
}
int j = 0;
node2 = node.Item(2);
foreach (XmlNode var in node2.ChildNodes)
{
foreach (XmlNode var1 in var.FirstChild)
{
switch (var1.Name)
{
case "adlcp:location":
xml.url[j] = var1.InnerText;
++j;
break;
default:
break;
}
}
}
for (int i = 0; i < xml.url.Length; i++)
{
if (i == 0)
{
Console.Write("序号\t\t节点名称\t\tURL");
Console.WriteLine();
Console.Write(i + 1 + "\t\t" + xml.title + "\t\t0");
}
else
{
if (xml.name[i - 1] == null)
{
break;
}
Console.Write(i + 1 + "\t\t");
Console.Write(xml.name[i-1] + "\t\t");
Console.Write(xml.url[i-1] + "\t\t");
}
Console.WriteLine();
}
}
}
}
}Xml.cs类using System;
using System.Collections.Generic;
using System.Text;namespace TestConsoleApplication
{
public class Xml
{
public string title;
public string[] name = new string[10];
public string[] url = new string[10];
}
}把你的你的发的那个XML文件放到E盘跟目录下..
没有人给出有用的方法.
dom.LoadXml(xml);
foreach (System.Xml.XmlNode node in dom.ChildNodes)
{
Console.Write(Get(node)+" <BR>");
}
string Get(System.Xml.XmlNode node)
{
string str = node.InnerText;
if (node.HasChildNodes)
{
str = "";
foreach (System.Xml.XmlNode n in node.ChildNodes)
{
str += Get(n);
}
}
return str;
}