This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
How to get the value of an attribute from XML file in PHP?
(4 answers)
Closed 11 months ago.
The structre of the xml is
<Song FilePath="netsearch://va381553" Flag="2305">
<Tags Author="Bananarama" Title="Venus 2018 " Genre="Dance" Remix="JRMX Club Mix [Single]" Year="2018" Bpm="0.476190" Flag="1" />
<Infos SongLength="305.0" LastModified="1641382448" FirstSeen="1641381390" Bitrate="320" Cover="32" />
</Song>
I need to extract only from the attributes 'Author' & 'Title' from <Tags Author="Bananarama" Title="Venus 2018" ...
Looping through the xml and inserting to the db - I've never needed to do this so How would I go about this please?
Related
This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
Closed 7 years ago.
I am integrating with an API which returns data in XML format. I receive a response from the API and store it in a variable named $result. How do I access the clientdetails values from the example response below?
<client_get>
<header>
<messagetype>Response</messagetype>
<submissionnumber>563jd94a2jfoi4f</submissionnumber>
</header>
<clientdetails>
<clientid>23373920</clientid>
<companyname>Testing Test</companyname>
<accountreference>1133</accountreference>
<status>LIVE</status>
</clientdetails>
<gocardlessdetails>
<newsignupurl>https://www.url here>
</gocardlessdetails>
</client_get>
If you can call an external process, there are command line splitters out there. One, xmlsplit, has an option to automatically include that header element in each of the split files, but it is commercial. There are also OS XML splitters.
This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
Closed 7 years ago.
How can I parse this xml, and get url text and title node value seperated:
<root>
<test>
<gate>
<url>http://google.com<title>Google</title></url>
</gate>
</test>
</root>
Is this possible with DomDocument or SimpleXML ?
Try with this:
$data = simplexml_load_file("file.xml");
echo $data->root->test->gate->url
This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
Closed 8 years ago.
<root>
<status>Call Triggered Successfully</status>
<is_ndnc>no</is_ndnc>
<callid>aaac5814-400f-45ea-9235-f0198e5edd4b</callid>
</root>
how can Read nodes i hv to assign to variable
like
$status='Call Triggered Successfully';
$is_ndnc='no';
$callid='aaac5814-400f-45ea-9235-f0198e5edd4b';
There are many ways in which you can gt the nodevalue from xml in php.
You could use xpath which returns an array of SimpleXMLElement objects.
Or you could load the file with simplexml_load_file() and use the foreach loop as explained here
This question already has answers here:
simple xml add namespaced child
(2 answers)
Closed 5 years ago.
I will have to produce this XML using simpleXML in php:
<fr:program name="fundref">
<fr:assertion name="funder_name">ABC Inc.
<fr:assertion name="funder_identifier">http://dx.doi.org/10.13039/xxxxxxxxxx</fr:assertion>
</fr:assertion>
<fr:assertion name="award_number">BXDFSDS</fr:assertion>
</fr:program>
I tried:
$fundRef = $myXML->addChild('fr', '', 'program');
But this is creating:
<fr xmlns="program" name="fundref">
Thank you.
You need to determine namespace like this
$myXML->addChild('fr:program', '', 'http://ololo.com/ns/1.0');
This should help PHP's SimpleXML: How to use colons in names
This question already has answers here:
How do you parse and process HTML/XML in PHP?
(31 answers)
DOMDocument for parsing HTML (instead of regex)
(2 answers)
Closed 9 years ago.
I want to get the text from a div in this page:
<html>
<head>Hello world!</head>
<body>
This is a test!<br>Hello man!<br>
<div class="special">
I want this text
</div>
</body>
</html>
I am using this code to get the content without any tags:
echo strip_tags(file_get_contents('http://website.com'));
However, I would like only to get the content from the
<div class="special">
from that page. Is that possible in PHP?
Use a HTML parser to parse the object you read using file_get_contents(). This question lists a bunch of parsers you could use