simplexml_load_string not displaying all contents inside of its element (PHP and XML)

Viewed 250

I can't get the whole data from XML when transforming it using simplexml_load_string

Example: partial data of XML

<variable ident="592952" type="single" cint:sort-order="1"
cint:hide-on="Registration"
cint:country-language-question-id="2222">

When i used simplexml_load_string and wrap them at json_encode and json_decode to become array, it will look like this:

+"variable": SimpleXMLElement {#550 ▼
            +"@attributes": array:2 [▼
              "ident" => "782752"
              "type" => "single"
            ]

Question: How can i get the value of cint:sort-order="1" from the variable element in XML form and put it together with some variables and to look like this? Is this possible?

"variable": SimpleXMLElement {#550 ▼
                +"@attributes": array:2 [▼
                  "ident" => "782752"
                  "type" => "single",
                  "cint:sort-order" =>"1",
                  "cint:hide-on" =>"Registration",
                  "cint:country-language-question-id" =>"2222"
                ]
0 Answers
Related