System.Xml.XmlException: The ':' character, hexadecimal value 0x3A, cannot be included in a name.

Posted on 2011-10-26
Last Modified: 2012-05-12
Hi All,

I am really stuck at the moment.. I have been looking this error up on the iternet for ages but cannot see how it fits with what I am doing....

I copied the following code which is supposed to merge PowerPoint files using OpenXML but when running the code I get the following error:

System.Xml.XmlException: The ':' character, hexadecimal value 0x3A, cannot be included in a name.

at line..

destSp = destinationPresentationPart.AddPart<SlidePart>(sp, relId);

... which is within the 3rd code snippet in point 7 of the article.

Can anyone suggest when I could change this code to make it work?,,, It appears to be an XML error but I don't have control of the XML a its a MS PowerPoint 2010 file its referring to I believe.

Any help would be much much appreciated... I have spent 2 weeks on Open XML and have found it difficult to pick it up! :-(

I have attached the code too.

Many thanks,

private void MergePresentationSlides(string sourcePresentation, string destinationPresentation)
            int id = 0;
            //Open destination presentation
            using (PresentationDocument myDestDeck = PresentationDocument.Open(destinationPresentation, true))
                PresentationPart destinationPresentationPart = myDestDeck.PresentationPart;

                if (destinationPresentationPart.Presentation.SlideIdList == null)
                    destinationPresentationPart.Presentation.SlideIdList = new SlideIdList();

                using (PresentationDocument mySourceDeck = PresentationDocument.Open(sourcePresentation, false))
                    PresentationPart sourcePresentationPart = mySourceDeck.PresentationPart;

                    //Get unique IDs for the slides master and slide lists for us later.
                    uniqueID = GetMaxSlideMasterID(destinationPresentationPart.Presentation.SlideMasterIdList);
                    uint maxSlideID = GetMaxSlideId(destinationPresentationPart.Presentation.SlideIdList);

                    //Copy each slide in the source presentaiton and order of the destination presentation
                    foreach (SlideId slideId in sourcePresentationPart.Presentation.SlideIdList)
                        SlidePart sp;
                        SlidePart destSp;
                        SlideMasterPart destMasterPart;
                        string relId;
                        SlideMasterId newsSlideMasterId;
                        SlideId newsSlideId;
                        // Create a unique relationship Id.
                        sp = (SlidePart)sourcePresentationPart.GetPartById(slideId.RelationshipId);
                        relId = sourcePresentation.Remove(sourcePresentation.IndexOf('.')) + id;
                        //Add the slide part to the destination presentation.
                        destSp = destinationPresentationPart.AddPart<SlidePart>(sp, relId);
                        //The master part was added so make sure the relationship is in place
                        destMasterPart = destSp.SlideLayoutPart.SlideMasterPart;
                        //Add slide master to slide master list
                        newsSlideMasterId = new SlideMasterId();
                        newsSlideMasterId.RelationshipId = destinationPresentationPart.GetIdOfPart(destMasterPart);
                        newsSlideMasterId.Id = uniqueID;
                        //Add slide to slide list
                        newsSlideId = new SlideId();
                        newsSlideId.RelationshipId = relId;
                        newsSlideId.Id = maxSlideID;

                    //Make sure all slide IDs are unique
                //Save the changes to the destination deck


Open in new window

Question by:rito1
    LVL 17

    Accepted Solution

    Either ID or RelId contains a ':'. A : is used in XML to separate the namespace from the name, and cannot be included into a name because of that.

    Can you put a breakpoint on that line in the debugger and check the actual values in there?
    LVL 1

    Author Closing Comment

    After using VS debugger I found the culprit.



    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now