[Gambas-user] gb.xml "unSerialize"

Adrien Prokopowicz adrien.prokopowicz at ...626...
Sat Oct 19 15:56:44 CEST 2013


I just added the new static method XMLNode.Deserialize() in revision #5906  
for this purpose. For example,

Print XMLNode.Deserialize("Select * From mytable Where id < 10")

Will print : Select * From mytable Where id < 10

Caveat : If you use the FromText() method, you don't actually need to put  
your text in any element. Text nodes are nodes too. :)

Just be careful not to give an empty string, otherwise FromText() will  
give you back an empty array, and accessing myNoddies[0] will raise an  
"Out of bounds" error !

Fabien : the "short way" of doing this would actually be :

Print XMLElement.FromText("text")[0].TextContent (again, while ensuring  
that the given text is not empty).
FromText() returns an array of nodes. :)


Regards,

-- 
Adrien Prokopowicz

Le Sat, 19 Oct 2013 11:45:03 +0200, Fabien Bodard <gambas.fr at ...626...> a  
écrit:

> Le 19 oct. 2013 11:23, "Caveat" <Gambas at ...1950...> a écrit :
>>
>> Just use FromText...
>>
>>    Dim myNoddies As XMLNode[]
>>    Dim aNode As XMLNode
>>    myNoddies = XMLElement.FromText("<SQL>Select * From table1 where abc
>> < 123</SQL>")
>>    Print myNoddies.Count
>>    aNode = myNoddies[0]
>>    Print aNode.TextContent
>>
>> Returns:
>> 1
>> Select * From table1 where abc < 123
>>
>
> Well
>
> Print xmlelement.fromtext("text").content
>>
>> Kind regards,
>> Caveat
>>
>> On 19/10/13 11:09, Bruce wrote:
>> > What is the opposite of XMLElement.Serialize(text as String)?
>> >
>> > ( I want my SQL text back as "... WHERE rdate<current_date..." instead
>> > of "... WHERE rdate<current_date...")
>> >
>> > tia
>> > Bruce




More information about the User mailing list