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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:12:36+00:00 2026-06-03T00:12:36+00:00

I posted a question regarding this about how to figure attribute values before. Even

  • 0

I posted a question regarding this about how to figure attribute values before. Even though I figured that I cannot delete the element which has this attribute. I try searching but still I can’t find a proper working answer. I really hope you can help me. This is my code. I go though xml document looking for the attribute value and then try to delete the parent node of the node that has this attribute value.

        $xml = new SimpleXMLElement($xmlfile,0,true);

        $results = $xml->xpath("/presets/preset");

        foreach ($results as $result) {
        foreach ($result->children() as $second_gen) {
            if($second_gen->getName()=='name'){
                foreach($second_gen->attributes() as $a => $b) {
                    if($b==$preset_name){
                        echo($b);
                            echo($preset_name);
                            unset($result);
                        }

                }
            }

        }
        }
        $xml->asXML();

As a result of executing this code I get no errors and I have correct $b and $preset_name echoed. But node is not getting deleted. It’s still there in the document.

My xml file looks like:

 <presets>
 <preset>
 <name code="default">Default</name>
  <createdBy>p</createdBy>
   <icons>q</icons>
 </preset>
 <preset>
   <name code="new_preset">New Preset</name>
    <createdBy>x</createdBy>
   <icons>y</icons>
 </preset>
 ...
 </presets>
  • 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-03T00:12:37+00:00Added an answer on June 3, 2026 at 12:12 am

    I found a simple answer without using SimpleXMLElement class. Check this out for my complete answer.
    How can i get the value of attribute in of a xml node in php?

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

Sidebar

Related Questions

Yesterday I posted this question regarding using lambdas inside of a Join() method to
A while back I posted a different question regarding column order. While this question
I asked a question regarding Bi linear transformations and received this answer: From that
i have questions regarding the shake detection that posted here before, here is a
I'm trying to figure out something regarding rails relationships. I already posted a question
I understand that there has been countless of question posted here regarding opacity issues
Previously I posted a question regarding multithreading. Actually my intension is to send SMS
I recently posted a question which was answered by Bryan Watts, regarding generic repository
I posted a question last night about Java Reflection and am discovering compiler warnings
I posted this question on Reddit Programming and did not get a single response.

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.