How to read XML with schema in Laravel?

I am using Laravel 5 and currently have problems with parsing my xml from soap web service. Idea is to get XML from soap, and parse it to array and then insert each row in database, so that’s why i need to parse it (otherwise for display i would only display it). At the moment i am using This parser but on my XML with schema in it and it only returns empty array [].

If i send XML without schema then parsing can be done.

Example of XML with shema is:


<?xml version="1.0" encoding="windows-1250" ?>
<xml xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema">
<s:Schema id="RowsetSchema">
<s:ElementType name="row" content="eltOnly" rs:updatable="false">
<s:AttributeType name="SifKup" rs:number="1" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pZup" rs:number="2" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="poPC" rs:number="3" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pNas" rs:number="4" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pMo" rs:number="5" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pUli" rs:number="6" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pKbr" rs:number="7" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pKpbr" rs:number="8" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="pBrStan" rs:number="9" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="psifPod" rs:number="10" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pHodogram" rs:number="11" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="pNaziv1" rs:number="12" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="pNaziv2" rs:number="13" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="pAdresa" rs:number="14" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="pMjesto" rs:number="15" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="SifBro" rs:number="16" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="LokBro" rs:number="17" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="SifSkiceV" rs:number="18" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="Datprvo" rs:number="19" rs:nullable="true" rs:write="true">
<s:datatype dt:type="dateTime" rs:dbtype="timestamp" dt:maxLength="16" rs:scale="3" rs:precision="23" rs:fixedlength="true" rs:maybenull="true" />
</s:AttributeType>
<s:AttributeType name="Godpro" rs:number="20" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="GodZig" rs:number="21" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:AttributeType name="Proizv" rs:number="22" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="SlOznakaB" rs:number="23" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="Dimenzija" rs:number="24" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="Tip" rs:number="25" rs:nullable="true" rs:write="true">
<s:datatype dt:type="string" dt:maxLength="1024" />
</s:AttributeType>
<s:AttributeType name="DatZadOcit" rs:number="26" rs:nullable="true" rs:write="true">
<s:datatype dt:type="dateTime" rs:dbtype="timestamp" dt:maxLength="16" rs:scale="3" rs:precision="23" rs:fixedlength="true" rs:maybenull="true" />
</s:AttributeType>
<s:AttributeType name="ZadnjeOcit" rs:number="27" rs:nullable="true" rs:write="true">
<s:datatype dt:type="int" dt:maxLength="16" />
</s:AttributeType>
<s:extends type=" rs:rowbase" />
</s:ElementType>
</s:Schema>
<rs:data>
<z:row SifKup="9999999" pZup="22" poPC="2" pNas="21" pMo="0" pUli="25" pKbr="34" pKpbr="" pBrStan="0" psifPod="10" pHodogram="0" pNaziv1="aaa" pNaziv2="Gubaševo 34, zabok" pAdresa="aaaaa" pMjesto="aaa" SifBro="5737560841" LokBro="3/4" SifSkiceV="0" Godpro="0" GodZig="0" Proizv="" SlOznakaB="" Dimenzija="" Tip="" DatZadOcit="2022-09-24T00:00:00" ZadnjeOcit="89" />

....other data

</rs:data>
</xml>

Example of XML without schema is:


<xml>
<zapis>
<sif>1</sif>
<naziv>abcd</naziv>
</zapis>
<zapis>
<sif>2</sif>
<naziv>gggggg</naziv>
</zapis>
<zapis>
<sif>3</sif>
<naziv>asdasddasf</naziv>
</zapis>
<zapis>
<sif>4</sif>
<naziv>xxxxxc</naziv>
</zapis>

<zapis>
<sif>5</sif>
<naziv>ccccccc</naziv>
</zapis>

<zapis>
<sif>6</sif>
<naziv>bbbbbb</naziv>
</zapis>

</xml>

My code is:


//$xmlData is my XML as string
$parser = new Parser();
$parser->payload('application/xml');
$output = $parser->xml($xmlData);
dd($output);

So my question is how to do it properly? Do i have to parse XML with schema in XML without schema which is not likely because i don’t have access to API which gives me XML as result (string) or there is some other alternative way to do it in Laravel?

from Newest questions tagged laravel-5 – Stack Overflow http://ift.tt/1Z5w2LU
via IFTTT

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.