Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:29:20+00:00 2026-05-24T09:29:20+00:00

$doc = new DOMDocument(); $doc -> load(state.xml); …snip… $neworder = $doc -> createElement(order); $neworder

  • 0
$doc = new DOMDocument();
$doc -> load("state.xml");
...snip...
$neworder = $doc -> createElement("order");
    $neworder -> appendChild($type);

That last line of code is causing the script to fail. 500 HTTP response. If I comment it out, the script runs fine.

get_class() confirms that both $neworder and $type are of the DOMElement class. What could the problem be?

…

On where I’m getting the nodes I’m trying to add:

This is where $type comes from.

for ($i = 0; $i < $ordersummary -> length; $i++)
{
   $o = $ordersummary -> item($i);
   $type = $o -> getElementsByTagName("type") -> item(0);
   ...

and $ordersummary is obtained like this

$ordersummary -> loadXML($_POST["data"]);
$ordersummary = $ordersummary -> getElementsByTagName("order");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:29:22+00:00Added an answer on May 24, 2026 at 9:29 am

    The Exception is thrown because you try to append a node from one Document into another. That is not supported by the DOM API.

    EDIT: The only sane workaround is to deep-copy the element. Depending on whether or not type is a complex XML structure it may be just a lot easier to serialise the type node to XML string, then create a DOMDocumentFragment for the receiving DOMDocument object and load the raw XML into this DOMDocumentFramgnent. Then you can append the DOMDocumentFragment as you would a DOMElement to insert the type XML data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

private void BindCountry() { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath(countries.xml)); foreach (XmlNode node in
XmlDocument doc = new XmlDocument(); doc.AppendChild(doc.CreateElement(Foo)); doc.DocumentElement.InnerXml = Test; StringBuilder result = new StringBuilder();
My Code: // Read in Xml-file XmlDocument doc = new XmlDocument(); doc.Load(C:/Web.config); XmlNode d
$xml = '<p><a>1</a><b><c>1</c></b></p>'; $dom = new DomDocument; $dom->loadXML($xml); $p = $dom->childNodes->item(0); echo $dom->saveXML($p); the
The example on codeplex is this : HtmlDocument doc = new HtmlDocument(); doc.Load(file.htm); foreach(HtmlNode
Why does running this code... XmlDocument doc = new XmlDocument(); string xml = @<?xml
i uses dom doc to load html from database like this: $doc = new
here's my code: XmlDocument doc = new XmlDocument(); foreach (string c in colorList) {
Using .NET and the Word Interop I am programmatically creating a new Word doc
How to create new PCL file similar to existing MS doc. I have MS

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.