Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.


XML 'cannot bind to reserved namepace'

XML 'cannot bind to reserved namepace'

Hi there, I have a issue with my XML not binding the namespace, please advise, i have taken some words out and replaced with*

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;
using System.Xml;
using System.Xml.Schema;
using OAI_Framework.Exceptions;
using System.IO;

public string myXMLDoc(string recVerb, string recIdentifier)
            XmlDocument _xmlDoc = new XmlDocument();
            XmlSchema schema = new XmlSchema();
            schema.Namespaces.Add("xmlns", "****.xsd");

            XmlDeclaration _dec = _xmlDoc.CreateXmlDeclaration("1.0", "utf-8", null);
            //Date and Time
            string recResponsDate = FormatDate(DateTime.Now, "ResponseDate");
            string recDateStamp = FormatDate(DateTime.Now, "ResponseDate");

              Root Element
            XmlElement _root = _xmlDoc.CreateElement("OAI-PMH","***.xsd");

            XmlAttribute _rootAtr_xmlns = _xmlDoc.CreateAttribute("xmlns", "");
            XmlAttribute _rootAtr_xmlnsXsi = _xmlDoc.CreateAttribute("xmlns", "xsi", "");       
            XmlAttribute _rootAtr_SchemaLoc = _xmlDoc.CreateAttribute("xsi", "schemaLocation", "");
            _rootAtr_xmlns.Value = "";
            _rootAtr_xmlnsXsi.Value = "";
            _rootAtr_SchemaLoc.Value = "***.xsd";


              Response Date
            XmlElement _responseDate = _xmlDoc.CreateElement("responseDate", "");
            _responseDate.InnerText = recResponsDate;            

            XmlElement _request = _xmlDoc.CreateElement("request", "***.xsd");

            XmlAttribute _requestAtr_verb = _xmlDoc.CreateAttribute("verb", "");
            XmlAttribute _requestAtr_ID = _xmlDoc.CreateAttribute("identifier", "");
            XmlAttribute _requestAtr_MetaDatePrefix = _xmlDoc.CreateAttribute("metadataPrefix", "***.xsd");
            _requestAtr_verb.Value = recVerb;
            _requestAtr_ID.Value = recIdentifier;
            _requestAtr_MetaDatePrefix.Value = "oai-dc";


            _request.InnerText = "";


              Record Type to Pull (verb)
            XmlElement _verbTypeToPull = _xmlDoc.CreateElement(recVerb, "***.xsd");
                XmlElement _record = _xmlDoc.CreateElement("record", "");                
                    XmlElement _header = _xmlDoc.CreateElement("header", "");
                            XmlElement _header_SUBELEMENT_identifier = _xmlDoc.CreateElement("identifier", "");
                            _header_SUBELEMENT_identifier.InnerText= "***" + recIdentifier;
                            XmlElement _header_SUBELEMENT_datestamp = _xmlDoc.CreateElement("datestamp", "");
                            _header_SUBELEMENT_datestamp.InnerText = recDateStamp;
                    XmlElement _metadata = _xmlDoc.CreateElement("metadata", "");                   
                        XmlElement _dc = _xmlDoc.CreateElement("oai_dc", "dc", "");

                        XmlAttribute _dcAtr_oaiDC = _xmlDoc.CreateAttribute("xmlns", "oai_dc", "");
                        XmlAttribute _dcAtr_dc = _xmlDoc.CreateAttribute("xmlns", "dc", "");
                        XmlAttribute _dcAtr_schemaLocation = _xmlDoc.CreateAttribute("xsi","schemaLocation", "");

                        _dcAtr_oaiDC.Value = "";
                        _dcAtr_dc.Value = "";
                        _dcAtr_schemaLocation.Value = "";

                              ALL ELEMENTS(RECORDS) OF OAI_DC
                            int _dsID = Convert.ToInt32(_identifier.Substring(_identifier.LastIndexOf(":")+1));
                            //Get record
                            SqlDataReader reader = SqlHelper.ExecuteReader(_connString, "usp_AOI_GetDataset", _dsID);

                            //Convert to xml
                            if (reader.Read())
                                if (!reader.IsDBNull(0)) //identifier
                                    XmlNode _emtIdentifier = _xmlDoc.CreateNode(XmlNodeType.Element, "dc", "identifier", "");
                                    _emtIdentifier.InnerXml = reader["identifier"].ToString();
                                if (!reader.IsDBNull(1)) //title
                                    XmlNode _emtTitle = _xmlDoc.CreateNode(XmlNodeType.Element, "dc", "title", "");
                                    _emtTitle.InnerXml = reader["title"].ToString();
                                if (!reader.IsDBNull(2)) //creator
                                    XmlNode _emtCreator = _xmlDoc.CreateNode(XmlNodeType.Element, "dc", "creator", "");
                                    _emtCreator.InnerXml = reader["creator"].ToString();
                                if (!reader.IsDBNull(3)) //description
                                    XmlNode _emtDescription = _xmlDoc.CreateNode(XmlNodeType.Element, "dc", "description", "");
                                    _emtDescription.InnerXml = reader["description"].ToString();
                                XmlNode _emtDate = _xmlDoc.CreateNode(XmlNodeType.Element, "dc", "date", "");
                                _emtDate.InnerXml = recDateStamp;
            StringWriter strWriter = new StringWriter();
            XmlTextWriter xmlWriter = new XmlTextWriter(strWriter);
            xmlWriter.Formatting = Formatting.Indented;
            xmlWriter.Namespaces = true;

            return strWriter.ToString();

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close