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

  • Home
  • SEARCH
  • 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 9150575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:37:46+00:00 2026-06-17T11:37:46+00:00

In order to simulate XML retrieved from a SOAP web service in a local

  • 0

In order to simulate XML retrieved from a SOAP web service in a local php test environment version of the web service, I wish to add an empty namespace to an element, just as supplied by the actual web service itself.

But when I add a null string namespace argument to the addChild method, it is not added. Any other value does give me a namespace, but as I said I wish to have an empty one.

So

$xml = new SimpleXMLElement('<cdhead/>');
$nako = $xml -> addChild ('nako', '000', '');

gives me

<cdhead>
    <nako>000</nako>
</cdhead>

But I wish to have

<cdhead>
    <nako xmlns="">000</nako>
</cdhead>

How can I achieve that?

  • 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-06-17T11:37:46+00:00Added an answer on June 17, 2026 at 11:37 am

    This problem is because you are using php 5.2. Its a bug and was fixed in the PHP 5.2 series. Here you can view the Bugreport. I’ve tested using PHP 5.3 and your example works out of the box. This should work in any case:

    <?php
    
    $xml = new SimpleXMLElement('<cdhead/>');
    $nako = $xml -> addChild ('nako', '000');
    $nako->addAttribute('xmlns', '');
    
    echo $nako->saveXml();
    

    It adds the attribute manually if the PHP version is lower than 5.3

    UPDATE I tried this with PHP 5.2.17-dotdeb too and it worked out of the box, both

    • addAttribute
    • addChild with empty string as namespace
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order to be able to simulate substr from PHP and mysql, I want
Order deny,allow deny from all allow from xx.xx.x.xx RewriteRule . - [F] I have
in order to recover data from server I use XMLHttpRequest and my code is
I have a PHP script that works by calling items from a database based
Is it possible to use given coordinates in order to simulate a click in
I'd like to wrap Prototype Ajax.Request in order to simulate AJAX latency. I mean,
I am trying to simulate n times the measuring order and see how measuring
Many data mining algorithms/strategies use vector representation of data records in order to simulate
I am writing a program to simulate cities from a game called Civilization 4.
I have successfully compiled a SystemC application that I use in order to simulate

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.