473,395 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XML Annoyance

Hey,

I am using C# to create an XML file in memory and then save it to a file. Everything is working
great apart from one thing which I can't figure out! :(

I have a few namespaces.. one is causing problems:

XmlDocument MANIFEST_XML_DOC = new XmlDocument();
XmlElement oManifest = MANIFEST_XML_DOC.CreateElement("manifest");

oManifest.SetAttribute("xmlns", "http://www.imsproject.org/xsd/imscp_rootv1p1p2");
oManifest.SetAttribute("xmlns:adlcp", "http://www.adlnet.org/xsd/adlcp_rootv1p2");
oManifest.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
oManifest.SetAttribute("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");

MANIFEST_XML_DOC.AppendChild(oManifest);
MANIFEST_XML_DOC.Save("imsmanifest.xml");

When the XML file is saves the schmeaLocation doesn't have the "xsi:" prefix.

Anybody know why??

Please help!

Thanks in adavce,

Anil

Dec 18 '06 #1
4 2370

oManifest.SetAttribute("schemaLocation","http://www.w3.org/2001/XMLSchema-in
stance",
"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");
Dec 18 '06 #2
Hi,

Instead of setting the namespace attributes manually, please review how
the 'XmlNamespaceManager' class works together with the XmlDocument class.

http://samples.gotdotnet.com/quickst...NameSpace.aspx

Best Regards,

Wiebe Tijsma

pl***@plank.com wrote:
Hey,

I am using C# to create an XML file in memory and then save it to a file. Everything is working
great apart from one thing which I can't figure out! :(

I have a few namespaces.. one is causing problems:

XmlDocument MANIFEST_XML_DOC = new XmlDocument();
XmlElement oManifest = MANIFEST_XML_DOC.CreateElement("manifest");

oManifest.SetAttribute("xmlns", "http://www.imsproject.org/xsd/imscp_rootv1p1p2");
oManifest.SetAttribute("xmlns:adlcp", "http://www.adlnet.org/xsd/adlcp_rootv1p2");
oManifest.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
oManifest.SetAttribute("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");

MANIFEST_XML_DOC.AppendChild(oManifest);
MANIFEST_XML_DOC.Save("imsmanifest.xml");

When the XML file is saves the schmeaLocation doesn't have the "xsi:" prefix.

Anybody know why??

Please help!

Thanks in adavce,

Anil
Dec 18 '06 #3
thanks that worked! :)

On Mon, 18 Dec 2006 08:35:29 -0500, "Raymond Basque" <_NOSPAM_rbasque@_NOSPAM_jednm.comwrote:
>
oManifest.SetAttribute("schemaLocation","http://www.w3.org/2001/XMLSchema-in
stance",
"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");
Dec 18 '06 #4
You're welcome. I ran across the exact same issue a while back -- I guess
you're doing some SCORM stuff. Tried using XmlNamespaceManager but it
wouldn't allow changing the value of "xmlns" -- it's reserved for use by
XML. Might be another way, but this worked for me.
Dec 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jegenye 2001 Bt | last post by:
Caveat: Python 2.2.2 (#37, Oct 14 2002, 17:02:34) Type "help", "copyright", "credits" or "l >>> l = >>> l 2 >>> l.__getitem__(1) 2 >>> l.__getitem__(slice(1))
8
by: caroundw5h | last post by:
PEP 292 adds a Template class to the string module that uses "$" to indicate a substitution. Template is a subclass of the built-in Unicode type, so the result is always a Unicode string: >>>...
0
by: Bloody Viking | last post by:
I've got an XSLT stylesheet which I've written and maintained for over 2 years now. I've always simply processed it with java org.apache.xalan.xslt.Process, but now I'm trying to speed things up,...
16
by: sloughin | last post by:
I realize that C# is a strongly typed language, but as a C++ programmer converting to C# I find the requirement that I typecast my integer enum values to be particularly annoying. Does anyone else...
5
by: Wiseguy | last post by:
consider the following: ostream_iterator<int> i(cout,""); cout << setw(3); copy(int_list.begin(),int_list.end(),i); the problem is that the field width restriction is only active for the...
0
by: PL | last post by:
It seems there is a bug or at least an annoynance with the new eventvalidation. I can't really tell you a certain way to reproduce this but I have a large datagrid that uses custom paging, I have...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.