Hey there! any question in your mind? Ask It Now!.

Popular Categories

I want parse and process HTML and XML in PHP?

0 votes
asked in Programming by navneet (270 points)

Can you help me i am trying to parsing HTML and XML and extract information ?

1 Answer

0 votes
answered by PRASHANT PATEL (300 points)
edited by Bhartesh

For parsing you can use HTML DOM to retrieve data , Like you can load DOM and can iterate the nodes as per your need for example

$doc = new DOMDocument();

// Get the sourcecode of the domain



//here we are collecting all div tags from web page

$div = $doc->getElementsByTagName('div');


foreach($books as $div)



$class = $div->getAttribute('class');

if (strpos($class, 'price') !== false)



echo $class->nodeValue;





For more understanding  you can see this Answer.


you also can use this script .




Related Questions

+1 vote
2 answers 184 views
+1 vote
2 answers 6,519 views
+2 votes
1 answer 176 views
+6 votes
3 answers 7,417 views
+2 votes
3 answers 359 views
+2 votes
1 answer 221 views
+4 votes
1 answer 708 views

Not a Member yet?

Ask to Folks Login

My Account
253 Folks are online
0 members and 253 guest online
Your feedback is highly appreciated