/    Sign up×
Community /Pin to ProfileBookmark

how to get list of arrays using DOMDocument?

I have the list of tags in php and I want to get the contents.

for example:

[CODE]
<li class=”zc-ssl-pg” id=”row0-1″ style=””>
<span id=”row1Time” class=”zc-ssl-pg-time”>6:00 PM</span>
<a id=”rowTitle1″ class=”zc-ssl-pg-title” href=’http://www.mysite.com’>Melissa & Joey</a>
<a class=”zc-ssl-pg-ep” href=’http://www.mysite.com’>”House Broken”</a>

<li class=”zc-ssl-pg” id=”row1-1″ style=””>
<span id=”row1Time” class=”zc-ssl-pg-time”>6:00 PM</span>
<a id=”rowTitle1″ class=”zc-ssl-pg-title” href=’http://www.mysite.com’>The Middle</a>
<a class=”zc-ssl-pg-ep” href=’http://www.mysite.com’>”Thanksgiving IV”</a>
[/CODE]

Here’s the PHP:

[CODE]
<?php
$qrytable1=”SELECT id, channels, links, streams FROM tvguide”;
$result1=mysql_query($qrytable1) or die(‘Error:<br />’ . $qry . ‘<br />’ . mysql_error());

$links = “WEBSITE URL”;
$result = file_get_contents($links);
$dom = new DOMDocument();
$dom->loadHTML($result);
echo $dom->getElementById(‘row1Time’)->nodeValue . “<br>”;
?>
[/CODE]

When I use the code as above, it will only get the contents from the tags with array value 0.

I want to get the tags `row1Time, rowTitle1 and zc-ssl-pg-ep with the array 1 value.

Can you please tell me how I can get the contents from the class tags with the array value 1 using with DOMDocument?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMar 28.2014 — Whatever do you mean by "array 1 value"? As it is, I don't see any array inputs which would be the only arrays I can think of, so what do you mean?

Besides - your code above contains a query that has no meaning and it only interrogates the loaded HTML for a single ID value. What did you expect it to do?
×

Success!

Help @mark107 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...