[Solved] Regex for HTML manipulation [closed]

It is bad practice to use regular expressions to parse HTML. Instead, use the tools provided in PHP that are specifically geared toward parsing HTML, namely DomDocument[doc]. // create a new DomDocument object $doc = new DOMDocument(); // load the HTML into the DomDocument object (this would be your source HTML) $doc->loadHTML(‘ <table> <tr> <td … Read more

[Solved] SimpleXML not working with Yahoo Answers [closed]

Firstly, you need to create instance of SimpleXML to use it. $bot = file_get_contents(“http://answers.yahooapis.com/AnswersService/V1/questionSearch?appid=API_KEY&query=”.$q1.””); $bot = simplexml_load_string($bot); echo $bot->Question[0]->ChosenAnswer; 1 solved SimpleXML not working with Yahoo Answers [closed]

[Solved] How to edit my code to save to mySQL from the beginning of XML?

This should work for you: <?php //Xml stuff $xml = simplexml_load_file(“file.xml”); //Database stuff $hostname = “localhost”; $username = “root”; $password = “”; try { //DB Connection $dbh = new PDO(“mysql:host=$hostname;dbname=dbname”, $username, $password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo “Connected to Database<br/>”; foreach($xml->products->product as $data) { $sql = “INSERT INTO XML_FEED (shop, product_id, product_name, product_link, product_image, product_category, product_price_with_vat) VALUES … Read more