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 1112565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:43:55+00:00 2026-05-17T02:43:55+00:00

After learning how to correctly unset a node , I noticed that using PHP’s

  • 0

After learning how to “correctly” unset a node, I noticed that using PHP’s unset() function leaves the tabs and spaces behind. So now I have this big chunk of white space in between nodes at times. I’m wondering if PHP iterates through blank spaces/returns/tabs and whether it would eventually slow down the system.

I’m also asking whether there’s an easy to remove the space unset leaves behind?

Thanks,
Ryan

ADDED NOTE:

This is how I removed the whitespaces after unsetting a node and it worked for me.

$dom = new DOMDocument();
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->load($xmlPath);
$dom->save($xmlPath);
  • 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-17T02:43:56+00:00Added an answer on May 17, 2026 at 2:43 am

    Wether it slows down the process: probably to little to care about.

    And simpleXML is just that, simple. If you require a ‘pretty’ output, DOM is your friend:

    <?php
    $xml = '
    <xml>
            <node>foo </node>
            <other>bar</other>
    </xml>';
    $x = new SimpleXMLElement($xml);
    unset($x->other);
    echo $x->asXML();
    
    $dom = new DOMDocument();
    $dom->preserveWhiteSpace = false;
    $dom->formatOutput = true;
    $dom->loadXML($xml);
    $dom->documentElement->removeChild($dom->documentElement->lastChild);
    echo $dom->saveXML();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm learning javascript. I know we can pass a function to other functions after
After learning that both strncmp is not what it seems to be and strlcpy
I'm learning currently php/mysql and I'm confused about this bit. After some heads scratching
I'm currently learning JPCT for Android. After reading some tutorials and examples, I've noticed
I'm currently learning ASP.NET, and read that the page validation occurs after Page.Load(). When
After learning good amount of c++, i'm now into STL containers and algorithms template
After learning about the Action delegate in C# I've been looking for ways I
I installed Visual Studio 2012 Ultimate RC this morning after learning about IntelliTrace at
Started learning Wicket after ASP.NET MVC and feel a little bit confused about managing
After spending three weeks learning Objective-C and Cocoa programming for my work, I've been

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.