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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:26:01+00:00 2026-05-27T05:26:01+00:00

I have this XML file: http://www.basket.ba/ksbih/xml/200_07.xml I’ve used all the major functions and classes

  • 0

I have this XML file: http://www.basket.ba/ksbih/xml/200_07.xml

I’ve used all the major functions and classes for the conversion of XML-to-Array, and couldn’t seem to get it work propertly.

Some of the elements were missing in the outputed data when “print_r/var_dump-ing” it.

First, I’ve tought there was a syntax error in the file, however that was not the case.

I need a super-dooper xml2array conversion. One thing might be useful:

If there’s a super-dooper simplexml2array conversion script/class/function, that might help even better as I will reduce my current code in that way,

  • 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-27T05:26:02+00:00Added an answer on May 27, 2026 at 5:26 am

    why don’t you use any class out of the internet?

    <?php
    class xml2array {
    
        function xml2array($xml) {
            if (is_string($xml)) {
                $this->dom = new DOMDocument;
                $this->dom->loadXml($xml);
            }
    
            return false;
        }
    
        function _process($node) { 
            $occurance = array();
    
            foreach($node->childNodes as $child) {
                $occurance[$child->nodeName]++;
            }
    
            if($node->nodeType == XML_TEXT_NODE) { 
                $result = html_entity_decode(htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), 
                                         ENT_COMPAT,'ISO-8859-15');
            } 
            else {
                if($node->hasChildNodes()){
                    $children = $node->childNodes;
    
                    for($i=0; $i<$children->length; $i++) {
                        $child = $children->item($i);
    
                        if($child->nodeName != '#text') {
                            if($occurance[$child->nodeName] > 1) {
                                $result[$child->nodeName][] = $this->_process($child);
                            }
                            else {
                                $result[$child->nodeName] = $this->_process($child);
                            }
                        }
                        else if ($child->nodeName == '#text') {
                            $text = $this->_process($child);
    
                            if (trim($text) != '') {
                                $result[$child->nodeName] = $this->_process($child);
                            }
                        }
                    }
                } 
    
                if($node->hasAttributes()) { 
                    $attributes = $node->attributes;
    
                    if(!is_null($attributes)) {
                        foreach ($attributes as $key => $attr) {
                            $result["@".$attr->name] = $attr->value;
                        }
                    }
                }
            }
    
            return $result;
        }
    
        function getResult() {
            return $this->_process($this->dom);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this XML at http://localhost/file.xml : <?xml version=1.0 encoding=utf-8?> <val:Root xmlns:val=http://www.hw-group.com/XMLSchema/ste/values.xsd> <Agent> <Version>2.0.3</Version>
I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I have this xml file: Response: <ns3:ExecuteResponse xmlns:ns3=http://www.opengis.net/wps/1.0.0 xmlns:ns1=net/ows/1.1 xmlns:ns2=http://www.w3.org/1999/xlink statusLocation=xxxxf62 serviceInstance=http:/http-post version=1.0.0 service=xxx>
I have xml file like this <?xml version=1.0 encoding=UTF-8?> <specification xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:noNamespaceSchemaLocation=file://Desktop/normal.xsd> <university> <refstr>bdvl_te_skrm_stc</refstr>
I have this XML file: <?xml version=1.0?> <xi:include href=http://www.w3schools.com/dom/books.xml xmlns:xi=http://www.w3.org/2003/XInclude/> and I expected that
I have this XML file: <movie id = 0> <Movie_name>The Shawshank Redemption </Movie_name> <Address>http://www.imdb.com/title/tt0111161/
I have this xml file: <?xml version=1.0 encoding=UTF-8?> <o-com-inter xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance version=1> <rules deplVer=125> <cre-det-r
I have this page: http://www.ryancoughlin.com/files/xml/ - if you select User -> Someones name You
We have XML file like below... <?xml version='1.0'?> <T0020 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.safersys.org/namespaces/T0020V1 T0020V1.xsd xmlns=http://www.safersys.org/namespaces/T0020V1> <IRP_ACCOUNT>
I have this xml file: <?xml version=1.0 encoding=utf-8 standalone=no?> <S2SDDIdf:MPEDDIdfBlkDirDeb xmlns:S2SDDIdf=urn:S2SDDIdf:xsd:$MPEDDIdfBlkDirDeb xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=urn:S2SDDIdf:xsd:$MPEDDIdfBlkDirDeb MPEDDIdfBlkDirDeb.xsd>

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.