Reputation: 1806
I need to load xml files and store them into a database. I'm using Symfony 2.1 as a framework and this framweork comes with a great tool - the crawler. It makes using XPATH easy.
How do I load XML files using this crawler?
Have you any a good tutorial showing how to do that?
Upvotes: 3
Views: 12512
Reputation: 36191
Have you tried this?
$document = new \DOMDocument();
$document->loadXml(file_get_contents('my_file.xml'));
$crawler = new Crawler();
$crawler->addDocument($document);
or this?
$crawler = new Crawler();
$crawler->addXmlContent(file_get_contents('my_file.xml'));
Read more on DomCrawler component and how to load content into it: http://symfony.com/doc/current/components/dom_crawler.html#adding-the-content
Upvotes: 8