XPathTester - A simple program to test XPath on the fly

in #utopian-io7 years ago (edited)

I feel like XPath is a seriously underrated gem. A lot of new developers seem to be completely ignorant of it.

What is XPath? XPath is a query language, that can be used to quickly parse through XML or HTML documents. If you need all elements with a certain css class? XPath can give it to you. You need all elements of a specific kind? Be it div, img, whatever, XPath can give it to you. Even things as specific as elements that contain certain text, with the right query, XPath can deliver.

That's why I created XPathTester. Born out of the necessity to quickly test XPath before putting any queries in production, and from the fat that there are very little non-paid programs that can allow you to quickly test XPath.

The way it works is very simple:

image.png

You type in the URL of the page you are looking to test (currently this program oes not accept local files) , you type in the XPath field the query you wish, and you press the "Get Content" button.

If everything works correctly, you should get a Node Count of how many elements you found with the query, and in the value field you will get the raw value that was pulled from your query (no raw HTML).

The User Agent and Cookie field are completely optional, but I had the necessity to put it in because certain websites will not allow the program to access their pages without standard user agents and cookies that they expect from their users (usually as security measures agaisnt bots).

If everything works correctly, your XPath query is valid and the website isn't blocking you for some reason, you will see something like this:

image.png

I tested this on http://google.com and pulled the @src property from the first img element I came across, but the potentials of xpath querying are huge.

If you are interested in learning about XPath, I recommend you read this tutorial from w3schools about how to use and create XPath queries.

Hope this program helps those who are searching for ways to test their XPath, and if you didn't know about XPath, I recommend you give it a chance :)

====================================================================

Shoutout to @Kaitto, a friend of mine that is trying to post about food and hobbies of his on Steemit. Look at his content, he is looking for new ways of growing and improving his posts. You will not be dissapointed.

Shoutout to @dynamicgreentk and @dynamicrypto for helping me learn more about Steemit and being friendly to new users who are trying to find their place in this platform.

====================================================================

I did not create this program for commercial means, nor was I expecting to get any money from it, I created it out of necessity and decided to share with you in hopes that it helps others the same way it helped me. If you liked it and wish to support other projects of mine, or wish for me to improve upon this, please donate Steem/BSD to my account @Krawller, even if it's only 0.01 Steem/BSD, it would really help. Every cent counts :)



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Please be more active in our discord! Your brilliant mind is a valuable resource! I appreciate you! Join the chat room or direct message me I have a special message for you when you have an opportunity...

Congratulations @krawller! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Do not miss the last post from @steemitboard:

SteemitBoard Ranking update - A better rich list comparator
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Congratulations @krawller! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

Click here to view your Board

Support SteemitBoard's project! Vote for its witness and get one more award!