advancedimport

Back
Run exampleDownload example
  • advancedimport [source],[xpath],[importashtml],[cache],[cachestorage],[clearcache]
    • check ($doc,$el)
    • eachnode ($el)
    • filter ($doc,$el)
    • runfirst ($doc,$el)

Same like import directive above, additionally has the ability to connect to the data sources using php streams. This means you will be able to make posts, bind connection to certain sockets, even use a proxy.
To parse remote files "allow_url_fopen" needs to be set to On in php.ini
Context: anywhere in //app/client

Remarks:
- the source document has to be valid (no missing tags)
- source attribute is optional; in case it does not exists the application's document itself is used;
- xpath attribute is mandatory
- advancedimport/runfirst is the first function to be executed, and is mainly used to change the attributes of import directive (xpath, source, importashtml,cache,...). If present, the document processor will create a lambda function from first processing instruction child of the runfirst node and execute it with $el parameter as the DOMNode of parent advancedimport directive
- if advancedimport/eachnode is present, the document processor will create a lambda function from first processing instruction child of the "eachnode" node and execute it with $el parameter as the DOMNode of each new node that is to be imported; if this function returns TRUE, the current node is imported, if returns FALSE or does not return anything the node is not imported; if returns a text value, this will be used to create a documentFragment to be used instead of the current node
- if advancedImport/check is given, the document processor will create a lambda function from the first processing instruction child of "check" node and will import the source or not, depending on the result of the function (function needs to return a value)
- if advancedImport/filter is given, the document processor will create a lambda function from the first processing instruction child of filter node and this function will be called with $doc parameter, awsXML (or awsHTML) instance on the local/remote file;

CACHING:

This basic cache system will store the remote resource only, for increased performance. To enable it you must set directive's cache attribute to "enable".

Other attributes to set:
- cachestorage - you must specify the name of the file (mandatory);
- clearcache number of seconds to wait before update the data source; if set to "FALSE" will store the data source content and never update it later; if set to "0" (zero) will update the data source each time directive is executed;