L
L
Lebnik2015-01-16 17:49:05
PHP
Lebnik, 2015-01-16 17:49:05

How to convert XML string to object?

Can't parse XML into object:

<?php
error_reporting(E_ALL);

$xml = <<<EOD
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://sharepoint.l/namespace.php" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
  <env:Body>
    <ns1:GetList env:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
      <param0 xsi:type="xsd:string">AA7D945C-E5C3-4854-B631-10A98E711E2B</param0>
    </ns1:GetList>
  </env:Body>
</env:Envelope>
EOD;

$sop = simplexml_load_string($xml);
var_dump($sop);

I get:
class SimpleXMLElement#1 (0) {
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lebnik, 2015-01-16
@Lebnik

I will answer myself.
Preliminary solution:

$sop = simplexml_load_string($xml);
$Body = $sop->children('http://www.w3.org/2003/05/soap-envelope');
$GetList = $Body->children('http://sharepoint.l/namespace.php');
$param0 = $GetList->children();
$code = (string)$param0;// получаем значение AA7D945C-E5C3-4854-B631-10A98E711E2B

as you can see, I didn’t succeed in converting XML into an object, but I managed to get to the bottom of the value of a certain tag, though through a stump-deck.

V
Vladislav, 2015-01-16
@MrBikus

Shouldn't there be an additional class_name parameter? php.net/manual/ru/function.simplexml-load-string.php

C
chimir, 2017-07-11
@chimir

Try like this:

@font-face {
  font-face: 'Mido Medium';
  src: url('../fonts/Mido-Medium.eot?#iefix') format('embedded-opentype'), 
       url('../fonts/Mido-Medium.woff') format('woff'), 
       url('../fonts/Mido-Medium.ttf') format('truetype');
}

but in general for modern browsers there are enough formats woffandwoff2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question