[pk_validxml]

Description

Link: [pk_validxml]
Author: Pier Kuipers
Category: XML
Version: 8.x
License: Public Domain
Posted: May. 09, 2006
Updated: Jul. 12, 2006
More by this author...
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 :-)

Parameters

-data string, required

Sample Usage

[
var('pseudo_serialized_data')='<arrayType><element><stringType>70</stringType>
</element>
</arrayType>';

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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

none

Email:


Password:



Newest

Most Popular