{"id":145,"date":"2007-02-22T20:57:57","date_gmt":"2007-02-23T01:57:57","guid":{"rendered":"\/cgi\/wp\/?p=145"},"modified":"2007-02-22T21:12:07","modified_gmt":"2007-02-23T02:12:07","slug":"regexbuddy-and-xmlnsmedia","status":"publish","type":"post","link":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=145","title":{"rendered":"RegexBuddy And xmlns:media"},"content":{"rendered":"<p>Today I purchased <a title=\"RegexBuddy\" href=\"http:\/\/www.regexbuddy.com\/\">RegexBuddy<\/a>, a tool for creating and testing regular expressions. Regular expressions are strings that <em>describe or match a set of strings, according to certain syntax rules. <\/em>In other words, a regular expression is a complex syntax for searching through text. It is very handy for search and replace and many mundane programming tasks that require text manipulation. I bought <strong>RegexBuddy<\/strong> because I am doing a lot of work with XSL, stylesheets for XML. Unfortunately, there are many occasions when XSL is not sophisticated enough to pull data from a RSS or XML feed. It is often necessary to do additional string parsing using JavaScript. One of the more useful features of JavaScript is its support for regular expressions. <strong>RegexBuddy<\/strong> is great for creating complicated regular expressions and testing them against sample data. It will even generate some of the JavaScript code you need to use regular expressions. <strong>RegexBuddy<\/strong> is only $29.95 so I found it affordable.<\/p>\n<p>I need to write some JavaScript functions for my XSL stylesheet I&#8217;m developing for the <strong>YouTube<\/strong> user RSS feed. This XML feed is using RSS 2.0 with the <strong>xmlns:media<\/strong> extension. The description tag has been causing me a lot of grief because it breaks the design principles of XML. The description tag actually contains 5 pieces of information; the video thumbnail, the video description, the author, the keywords or tags, and the date added. All of this information is provided as HTML within a <code><<code>!<\/code><\/code><code>[CDATA[...]]<\/code><code>><\/code>. <em>CDATA sections instruct the XML processor that the content included in a section is not markup and should not be parsed.<\/em> This makes it very difficult to extract the video description.<\/p>\n<p>So far I have written the JavaScript function to strip out the newlines in the HTML, because regular expressions don&#8217;t work well on multiline text, and the function to trim the description. I&#8217;ve also come up with a good regular expression to find the text contained within the first paragraph HTML tags <code><<\/code>p<code>><\/code><code><<\/code>\/p<code>> <\/code>which surround the video description. However, I am still having problems with the XSL which needs to pass the description element to my JavaScript function and then return a string I'll use within a title tag attribute as a tooltip. When you mouse over the video title I want to display the video description.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I purchased RegexBuddy, a tool for creating and testing regular expressions. Regular expressions are strings that describe or match a set of strings, according to certain syntax rules. In other words, a regular expression is a complex syntax for &hellip; <a href=\"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/?p=145\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/145"}],"collection":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=145"}],"version-history":[{"count":0,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=\/wp\/v2\/posts\/145\/revisions"}],"wp:attachment":[{"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=145"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/williamsportwebdeveloper.com\/cgi\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}