Frage

Jetzt kann ich eine Webseite über www :: mechanisieren navigieren und Informationen über < a href="http://p3rl.org/html%3a%3aTreebuilder%3a%3AXPath" rel="nofollow"> html :: treebuilder :: xpath Durch Zugriff auf eine ID, bin ich mit Firebug , um das DOM zu lesen, um das Layout des HTML-Baums zu ermitteln. Der Inhalt, der Captures mechanisieren, ist unstrukturiertes HTML, nicht gut für menschliche Augen.

verwendet Firebug, um die ID zu ermitteln, die ich nach einem typischen Ansatz bin? Sobald ich die ID bekomme, dann bin ich gut um diese Entdeckung einfacher zu machen. Obwohl er gewährt, macht Firebug es auch ziemlich einfach. Ich frage mich nur, ob ich eine einfachere Methode fehlt.

an Perlmonks befördert.

War es hilfreich?

Lösung

If you need text, xmllint --html --format (comes with libxml2) does a decent job.

If you want a tree and mess with it and test out various expressions in a GUI, then Xacobeo is your new best friend.

Xacobeo screenshot

Note: since both those tools rely on libxml, replace HTML::TreeBuilder::XPath with HTML::TreeBuilder::LibXML for compatibility. Evaluating XPath will be faster that way, too.


If you know Javascript/JQuery, then also install FireQuery. You can then test out CSS expressions in FireBug, and use them with modules that select HTML through CSS expressions, e.g. Web::Query.

FireQuery screenshot

Andere Tipps

I use XML Developer from Oxygen IDE for my recent development on XPath: http://www.oxygenxml.com/download.html It is a 30-day trial type of tool, but you can also search for XPath visualizer

It doesn't visualize a tree for you as far as I know (maybe there's a panel doing that). But it gives you some smart complete functionally that helps you to know what nodes you have available at any point. It is pretty big for XPath because it is hard to know where the parser pivot is really pointing at.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top