Le Tue, 17 Jun 2014 01:37:49 +0200, B Bruen <bbr...@paddys-hill.net> a  
écrit:

> (I'm sure I've done this before, but I can't find my prior code nor can  
> I find it in either of the help sites.)
>
> I just want to set a string variable to the text content of an element.   
> I am almost certain there was a way to have it automatically convert all  
> the "special character"s, like &nbsp, &lt, etc etc to their "normal"  
> representation.  Is there such a function, or was I just dreaming?
>
> tia
> Bruce
>

(Sorry about the late answer, I was quite busy these last few months ...)

The XmlNode.TextContent property is actually what you're looking for : it  
defines the node's text content without these entities. For example, this  
little code :

   Dim doc As New XmlDocument

   doc.FromString("<xml>Fish &amp; chips</xml>") 'This can be doc.Open(),  
doc.Content = "..." or whatever

   Print doc.ToString()

   Print doc.Root.TextContent

... will output this :

   <?xml version="1.0" encoding="UTF-8"?><xml>Fish &amp; chips</xml>
   Fish & chips

Moreover, you have the static couple of methods XmlNode.Serialize() and  
XmlNode.Deserialize() that allow you to convert strings back and forth  
between the "with entities" and "without entities" representations.

Regards,
-- 
Adrien Prokopowicz

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to