Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

ERror using xml AppendChild

Posted on 2014-10-09
3
171 Views
Last Modified: 2014-10-15
I am getting "The current node cannot contain other nodes." on the AppendChild.
What am I doing wrong?  MainDoc contains valid xml.  I am just trying to add an error message at the end of it.
element = errDoc.CreateElement("myError")
element.InnerXml = "<ErrorMsg>" & Msg & "</ErrorMsg>" & _
                   "<Exception>" & exception & "</Exception>"
errDoc.AppendChild(element)
MainDoc = errDoc.OuterXml

Open in new window

0
Comment
Question by:ToolTimeGang
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 40371955
Try changing line 4 to:
errDoc.DocumentElement.AppendChild(element)

Open in new window

0
 

Author Comment

by:ToolTimeGang
ID: 40372879
Robert....it worked like a charm!  Thank you!  
This code has been recompiled from .NET 1.1 to .NET 4.5.
So I guess I can expect deprecated things like this as I continue my journey through these recompiles ey?
0
 
LVL 35

Expert Comment

by:Robert Schutt
ID: 40372959
I'm not really sure, for your sake I hope not! To be honest I wasn't aware this has ever been possible (in this situation), thought I recognized a mistake I have made myself as far back as VB6. I guess it depends more on the object used than the specific language though. If it has been possible then I would say it was added in spite of the standard. Adding a second root element to the document should not be possible. Within its document element however not a problem.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 116
Hide vba in gp 7 104
Need a complete list of ASP.NET page load events 3 59
Eclipse Java import and method not resolved 4 50
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

828 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