Lasso Soft Inc. > Home

[pk_validxml]

Linkpk_validxml
AuthorPier Kuipers
CategoryXML
Version8.x
LicensePublic Domain
Posted09 May 2006
Updated12 Jul 2006
More by this author...

Description

Wrote this ultra-simple tag because I needed to do a quick check on data returned from several db columns, where some of the data might be serialized. The way to check if something is serialized is obviously to cast it to xml, but that will throw an error, which needs trapping. Anyway, the result is this tag :-)

Updated 2006-07-12 after remembering Johan's comment that the use of a page var will still cause problems - *now* it works :-)

Sample Usage

[
var('pseudo_serialized_data')='70

';

var('test_array')=null;

If(pk_validxml($pseudo_serialized_data));
	$test_array -> unserialize($pseudo_serialized_data);
Else;
	$test_array = $pseudo_serialized_data;
/If;

$test_array;
]

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

if: !(lasso_tagexists: 'pk_validxml');

	define_tag:'validxml', -namespace='pk_',
		-required='data',
		-description='establishes if data is valid xml';

		local('output')=false;

		if(local_defined('data'));
		
			protect;
				local('tryit') = xml:#data;
				local('result')='ok';
			/protect;

			if(local_defined('result'));
				#output = true;
			/if;

		/if;

		return(#output);

	/define_tag;

/if;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft