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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:29:51+00:00 2026-05-27T17:29:51+00:00

Hi I have following simple xml object: [ad] => Array ( [0] => SimpleXMLElement

  • 0

Hi I have following simple xml object:

[ad] => Array
    (
        [0] => SimpleXMLElement Object
            (
                [title] => <b>Title: Mysql 1</b>
                [abstract] => Abstract: Mysql 1
                [url] => www.Mysql.com
                [rurl] => http://sample/xtrack.php?rurldata=yes
                [iurl] => http://sample.com/
                [bid] => 0.0880
            )

        [1] => SimpleXMLElement Object
            (
                [title] => <b>Title: Mysql 2</b>
                [abstract] => Abstract: Mysql 2
                [url] => www.Mysql.com
                [rurl] => http://sample/xtrack.php?rurldata=yes
                [iurl] => http://sample.com/
                [bid] => 0.1980
            )
    )

I want to create an array from this. I am trying in foreach like this

foreach($xmlString->ad as $key){
        foreach($key as $key2 => $val2){
             $adData[$counter][$key2] = $val2;
        }
            $counter++;
}

But I get a structure like this:

 Array
  (
    [0] => Array
    (
        [title] => SimpleXMLElement Object
            (
                [0] => <b>Title: Mysql 1</b>
            )

        [abstract] => SimpleXMLElement Object
            (
                [0] => Abstract: Mysql 1
            )

        [url] => SimpleXMLElement Object
            (
                [0] => www.Mysql.com
            )

        [rurl] => SimpleXMLElement Object
            (
                [0] => http://sample/xtrack.php?rurldata=yes
            )

        [iurl] => SimpleXMLElement Object
            (
                [0] => http://sample.com/
            )

        [bid] => SimpleXMLElement Object
            (
                [0] => 0.0880
            )

    )
    .
    .
    .So on

now I know that $key2 is an object. How can i retrieve only tag name of that ? How to go about this?

  • 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-27T17:29:52+00:00Added an answer on May 27, 2026 at 5:29 pm

    This bellow example may helps you..

    XML File: student.xml

     <?xml version="1.0" encoding="UTF-8"?>
       <students>
          <student>
            <name>Hearaman</name>
            <age>24</age>
            <email>hearaman.dev@gmail.com</email>
            <address>Bangalore, India</address>
         </student>
     </students>
    

    PHP Code:

        <?php
        $xml = simplexml_load_file("student.xml");
    
        echo "Parent Tag = ". $xml->getName() . "<br />";
    
        foreach($xml->children()->children() as $child)
          {
          echo $child->getName() . ": " . $child . "<br />";
          }
        ?> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following simple xml object file: [AuthorList] => SimpleXMLElement Object ( [@attributes]
I have a simple Itemrenderer with the following code: <?xml version=1.0 encoding=utf-8?> <s:ItemRenderer xmlns:fx=http://ns.adobe.com/mxml/2009
I have a simple XML document <abc:MyForm xmlns:abc='http://myform.com'> <abc:Forms> <def:Form1 xmlns:def='http://decform.com'> .... </def:Form1> <ghi:Form2
I have the following XML: <?xml version=1.0 encoding=UTF-8?> <gnm:Workbook xmlns:gnm=http://www.gnumeric.org/v10.dtd xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.gnumeric.org/v9.xsd> <office:document-meta xmlns:office=urn:oasis:names:tc:opendocument:xmlns:office:1.0
I have a simple xml document that looks like the following snippet. I need
I have a large xml file (approx. 10 MB) in following simple structure: <Errors>
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following simple methods for writing a python object to a file
I have the following xml <Objects> <Object> <ViewAngle>90</ViewAngle> <ViewMode>ThirdPerson</ViewMode> <Top>50</Top> <Left>100</Left> </Object> </Objects> I
I have the following xml <Objects> <Object> <ViewAngle>90</ViewAngle> <ViewMode>ThirdPerson</ViewMode> <Top>50</Top> <Left>100</Left> </Object> </Objects> I

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.