I am creating very simple CMS for my organisation.
My strategy is to embed editable content between tags called < editable >. However to hide these from the browser I am commenting them out. So an example of an editable region will look like this.
<!-- <editable name="news_item> Today's news is ... </editable> -->
With the content “Today’s news is … ” being picked up by the CMS and made editable in the online HTML editor.
I would like to be able to “grab” the name attribute’s value as well as the content contained within the tags.
Is there a simple way to do this with XPath, XQuey type things, or is regex the best way to go ( ]esp. given that the regex will not need too much fault tolerance, since I know exactly what the xml will be, because I will be writing the code that generates it).
By DOM Parser, do you mean javascript? If so, this blog post suggests that you can indeed slice and dice HTML comments. And, because mentioning javascript without mentioning jQuery is a sin, here’s a jQuery plugin that will find all the HTML comments for you.