<?xml version="1.0" encoding="utf-8"?>
<!-- This is a SCORM 1.2 manifest file, created 9/1/2014 1:52:58 PM by semina using CourseLab 140211 -->
<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="MANIFEST-5D060C55_4EC0_4E49_8D2F_F5C934FFEDAD" version="1.0">
<title>Технолог подсистемы САДД БР. Работа с модулем «Справочники»</title>
<item identifier="im_1" identifierref="RES1" parameters="?width=1152&height=920">
<title>Информационный материал</title>
</item>
<item identifier="im_1" identifierref="RES1" parameters="?width=1152&height=920">
<title>Информационный материал</title>
</item>
</manifest>
XmlDocument data = new XmlDocument();
string path = AppDomain.CurrentDomain.BaseDirectory.Replace(@"\bin\Debug", @"");
path = path + "imsmanifest.xml";
XDocument data = XDocument.Load(path);
XElement track = new XElement("track",
new XAttribute("id", ""),
new XAttribute("genre", "Break Beat"));
IEnumerable<XElement> itemList = data.Elements("item");
foreach (XElement el in itemList) {
var childList = el.Elements();
if (childList.Last().Name == "title") {
el.Add(track);
}
}
data.Save(path);
var xml = XDocument.Parse(
@"<?xml version='1.0' encoding='utf-8'?>
<!-- This is a SCORM 1.2 manifest file, created 9/1/2014 1:52:58 PM by semina using CourseLab 140211 -->
<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='MANIFEST-5D060C55_4EC0_4E49_8D2F_F5C934FFEDAD' version='1.0'>
<title>Технолог подсистемы САДД БР. Работа с модулем «Справочники»</title>
<item identifier='im_1' identifierref='RES1' parameters='?width=1152&height=920'>
<title>Информационный материал</title>
</item>
<item identifier='im_1' identifierref='RES1' parameters='?width=1152&height=920'>
<title>Информационный материал</title>
</item>
</manifest>");
var ns = xml.Root.GetDefaultNamespace();
foreach (var element in xml.Root.Descendants().Where(e => e.Name == ns + "item"))
{
var last = element.Elements().Last();
if (last.Name == ns + "title")
{
last.AddAfterSelf(
new XElement("track",
new XAttribute("id", ""),
new XAttribute("genre", "Break Beat")));
}
}
<manifest xmlns="http://www.imsproject.org/xsd/imscp_rootv1p1p2"
xmlns:adlcp="http://www.adlnet.org/xsd/adlcp_rootv1p2"
xsi:schemaLocation="http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd
[url]http://www.imsglobal.org/xsd/imsmd_rootv1p2p1[/url] imsmd_rootv1p2p1.xsd"
>
string text = System.IO.File.ReadAllText(@"C:\\Users\\Ксюша\\Desktop\\1_2\\11.xml");
var xml = XDocument.Parse(text);
var ns = xml.Root.GetDefaultNamespace();
XNamespace xci = "http://www.w3.org/2001/XMLSchema-instance";
string srt = "";
string[] xciValue = new string[]{"http://www.imsproject.org/xsd/imscp_rootv1p1p2 imscp_rootv1p1p2.xsd",
"http://www.imsglobal.org/xsd/imsmd_rootv1p2p1 imsmd_rootv1p2p1.xsd"};
for (int i = 0; i < (xciValue.Count()); i++){
srt = srt + xciValue[i] + " ";
}
xml.Root.ReplaceAttributes(
new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
new XAttribute(xci + "schemaLocation", srt)
);
xml.Save("C:\\Users\\Ксюша\\Desktop\\1_2\\11.xml");
var xml = XDocument.Parse(text);