[Gambas-user] gb.xml "unSerialize"

Adrien Prokopowicz adrien.prokopowicz at ...626...
Sat Oct 19 16:59:20 CEST 2013


Le Sat, 19 Oct 2013 16:06:33 +0200, Benoît Minisini  
<gambas at ...1...> a écrit:

> Le 19/10/2013 15:56, Adrien Prokopowicz a écrit :
>> 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,
>>
>
> Shouldn't you use "Contents" instead of "Content". My dictionnary tells
> me that both are correct, but I have always seen the plural form.
>

I have seen both, but the singular form seems to be used too (like in the  
Content-Type HTTP header). This is also the form used in the DOM  
specification (see  
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Node3-textContent  
), so that's why I used "Content".

-- 
Adrien Prokopowicz




More information about the User mailing list