skip to Main Content

Php – Get name of second level tag in XML string

I am trying to fetch data from an XML file and have converted it to JSON. $xml = simplexml_load_file('types.xml','SimpleXMLElement',LIBXML_NOCDATA); $json = json_encode($xml); $array = json_decode($json,TRUE); The XML file contains data structured as: <types> <type name="ACOGOptic"> <nominal>15</nominal> <lifetime>14400</lifetime> <restock>1800</restock> <min>8</min> <quantmin>-1</quantmin>…

VIEW QUESTION

Can I loop through a SimpleXML object in PHP?

Hi I have an xml file like that <param typ="bool" nazwa="balkon">true</param> <param typ="bool" nazwa="lazienka_wc">true</param> <param typ="int" nazwa="liczbapieter">5</param> <param typ="int" nazwa="liczbapokoi">3</param> <param typ="int" nazwa="liczbalazienek">1</param> I am looping through this like that: foreach($oferta->param as $p){ print_r($p->attributes()->nazwa); } I print out nazwa attr…

VIEW QUESTION

Simplexml : xpath with three conditions – PHP

I have a xml file like this : <rss version="2.0" xmlns:atom="https://www.w3.org/2005/Atom"> <channel> <item> <city>London</city> <description>Trip</description> <link>page.php</link> <img>img.jpg</img> </item> <item> <city>London</city> <description>Trip</description> <link>page.php</link> <img>img.jpg</img> </item> <item> <city>Paris</city> <description>Trip</description> <link>page.php</link> <img>img.jpg</img> </item> . . </channel> </rss> If I want to select TRIP…

VIEW QUESTION

SimpleXML root node prefix php with default namespace declaration

I'm creating an xml file with PHP. The file I need to create is this one I show you: <p:FatturaElettronica versione="FPA12" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:p="http://microsoft.com/wsdl/types/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" versione="FPA12" > <FatturaElettronicaHeader> <DatiTrasmissione> <IdTrasmittente> <IdPaese>IT</IdPaese> <IdCodice>01234567890</IdCodice> </IdTrasmittente> <ProgressivoInvio>00001</ProgressivoInvio> <FormatoTrasmissione>FPA12</FormatoTrasmissione> <CodiceDestinatario>AAAAAA</CodiceDestinatario> </DatiTrasmissione> </FatturaElettronicaHeader> <p:FatturaElettronica> This is…

VIEW QUESTION

How find element in KML file in PHP

I try to find all elements <coordinates> into kml file, but not all of them have the same structure for example: <Placemark> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates> -103.6705130315019, 18.9861834531002, 312.462181927998 -103.5618913951496, 18.98673753736649, 827.0547547230755 -103.6101814498474, 19.21464825463783, 601.556189231858 -103.6705130315019, 18.9861834531002, 312.462181927998 </coordinates> </LinearRing>…

VIEW QUESTION

Remove a node from XML with namespace and generate new XML – Woocommerce

I am trying to filter the results of an XML feed generated for Facebook. Currently, the feed looks like this <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"> <channel> <title><![CDATA[Title]]></title> <link><![CDATA[https:/path/]]></link> <description>WooCommerce Product List RSS feed</description> <metadata> <ref_application_id>451257172939091</ref_application_id> </metadata> <item> <g:id>anID</g:id> <g:inventory>5</g:inventory>…

VIEW QUESTION
Back To Top
Search