I just hacked together a very simple class and CLI script to help me generate Google sitemap XML on a daily basis using PHP. If you have not yet heard of it: Google sitemaps help you promote your content if you have certain deep links that only show up if a visitor for example performs a search and clicks a result.
Check the documentation of the Google Sitemap Format
Here is the code: Google Sitemap Generator
It works like this:
$ php generate_gsitemaps.php; #will generate your standard sitemap
php generate_gsitemaps.php -e > my_sitemap.xml; #echo sitemap xml to another file
Have fun being found!
I had the case to build a WebService which had to be called transporting an array with some user data. This was the first time I was using an array as parameter in a SOAP-Service. Here are some examples that show what I figured out about how to setup the WSDL:
Notice the complexType ArrayOfString at the top in the types-element, which did the trick.
By the way: I could not get my favorite tool SOAPUI to build the appropriate SOAP-request for me in order to test my webservice. ZendStudio did not generate working WSDL in this case.
XPath Checker is a Firefox plugin that lets you mark areas in a webpage and returns the appropriate XPath query to select this bit. You can then change the query to see the selected values.
When starting to use XML-related technologies like XSL and XPath, the details and concepts can be intimidating in the first place. One question I had to solve was: How can I create a testing setup on my windows workstation that takes a XML source file and a ‘console’ from which I could execute XPath queries against that XML and see the result. This is comparable to having a mySQL table or database (your XML content) and shooting SQL queries to it via phpMyAdmin.
Here is the setup to get started:
(1) Preparations – do the following:
(2) Get your hands dirty:
- Start Cooktop and paste the XML Example into the XML-tab.
- If you have ugly XML or a machine generated oneline XML -> Menu ‘Tools’ / ‘Format current XML Tidy’.
- Be aware of namespaces! They have to be registered and used throughout your queries. It always confused me when testing, because the expected result is just empty nothing if you get that wrong. Solution: To simplify your test setup, make sure to delete all namespace info in the source XML. The example does not use a namespace, so we can forget about that for the moment.
- Go to the XPath-tab in Cooktop, read the instructions comment and delete it.
- All your XPath queries must be preceded by ‘nodes: ‘ or ‘values: ‘! Otherwise pressing the enter-key will not execute your query and just return the cursor to a new line.
- Write to a new line: ‘nodes: //dealnews_issues/name_de’ and press enter.
- You see the resulting nodes from your query. Cool!
- That’s what it is all about with XPath: Isolate a particular XML chunk to further process it in your software or use it in a XSL file for transformation into something different or check for existence or count elements etc. etc.
- Change your query to ‘values: //dealnews_issues/name_de’ and notice the difference.
- Now you can get a more complex XML content and play with it. Some good introductory examples of queries can be taken from my XPath Cheatsheet. You will soon discover that XPath can be very powerful and also fun to use.