Search

Can this be packed up in an extension that extends the Dynamic XML DS with a “Tidy” checkbox?

Thanks Phoque. That’s pretty much what I meant :)

If you don’t have access to the Tidy extension in your PHP, I echo Makenosound’s post, you could try YQL. I’m using it on one site and it works great.

This seems to be exactly what I’m looking for but I’m not clear on how to implement the code you posted above.

I’ll post my data source when I’m back at my desktop computer.

I couldn’t really remember how I used this code but having a look at the related project it seems quite simple: I just saved the snippet as a php file (changing the path to my source) and pointed a dynamic data source to it. If you need to call files dynamically you could just make use of $_GET which you could populate using variables in the data source settings.

Would be a great addition to the data source manager. If I find the time I could write a small step-by-step guide at the end of the week.

@Neither: YQL is almost certainly the easiest way to achieve what you want. As bzerangue points out above, it can use XPATH to traverse the returned HTML and give you back a well-formed XML tree with just the content you need. You should be able to use it simply by adding a dynamic datasource with the appropriate query in it. For example, the following query:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fgetsymphony.com%2Fdiscuss%2Fthread%2F220%2F2%2F%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2Fdiv%5B%40class%3D%22comment-body%22%5D'&format=xml

Pulls the div.comment-body from this page and generates this set of results:

<results>
  <div class="comment-body">
    <p>Can this be packed up in an extension that extends the Dynamic
XML DS with a &#x201C;Tidy&#x201D; checkbox?</p>
  </div>
  <div class="comment-body">
    <p>Thanks Phoque. That&#x2019;s pretty much what I meant :)</p>
  </div>
  <div class="comment-body">
    <p>If you don&#x2019;t have access to the Tidy extension in your
PHP, I echo Makenosound&#x2019;s <a href="http://getsymphony.com/discuss/thread/220/1/#position-19">post</a>,
you could try <a href="http://developer.yahoo.com/yql/guide/yql-select-xpath.html">YQL</a>.
I&#x2019;m using it on one site and it works great.</p>
  </div>
  <div class="comment-body">
    <blockquote>
      <p>This seems to be exactly what I&#x2019;m looking for but
I&#x2019;m not clear on how to implement the code you posted
above.</p>
    </blockquote>
    <p>I&#x2019;ll post my data source when I&#x2019;m back at my desktop
computer.</p>
  </div>
  <div class="comment-body">
    <p>I couldn&#x2019;t really remember how I used this code but having
a look at the related project it seems quite simple: I just saved
the snippet as a php file (changing the path to my source) and
pointed a dynamic data source to it. If you need to call files
dynamically you could just make use of <code>$_GET</code> which you
could populate using variables in the data source settings.</p>
    <p>Would be a great addition to the data source manager. If I find
the time I could write a small step-by-step guide at the end of the
week.</p>
  </div>
</results>

Thanks all!

Nils, that was pretty simple - cheers. Although after saving that previous code to a php file as you suggested and pointing a data source at it it returns the same “XML returned is invalid” error. Pointing my browser directly at the file just returns a blank page. After adding a couple of random echos through the document it seems that the PHP dies after the call to tidy() so I’m assuming (as bzerangue predicted) that’s caused by my MAMP installation not having that extension.

If so, then that’s the second thing MAMP has managed to cripple in my setup after the famous “Why can’t I export my ensemble?” lack of zip support.

Makenosound, that YQL is indeed an easy way to get this working and I’ve had pretty good success with it so far. Was reluctant at first to use a third-party service but after your explanation (thanks!) it seems pretty straight-forward. Only the url-encoding of the query is a little tricky.

In the future it would still be awesome to have an extension which just adds a “Tidy” checkbox to the dynamic XML datasource options. Just not for us crippled MAMP users… sigh.

It looks that Makenosound solution works like a charm.

I think Symphony should stay far as possible from PEAR extensions. Except If It’s absolutely necessary.

Was reluctant at first to use a third-party service but after your explanation (thanks!) it seems pretty straight-forward.

That’s fair enough, though I’d argue that Yahoo! and Google are likely to have far better uptime that your sites are (or at least my sites are). Another option is obviously is to cache the output of the YQL DS to protect against downtime at their end.

In the future it would still be awesome to have an extension which just adds a “Tidy” checkbox to the dynamic XML datasource options. Just not for us crippled MAMP users… sigh.

Completely agree!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details