put xml string with quotes?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
ThomasBodetti
Posts: 16
Joined: Tue May 14, 2013 12:30 pm

put xml string with quotes?

Post by ThomasBodetti »

I am curious if it is possible to put xml formatted data, into a variable or to add strings to a container.

Example,

Code: Select all

put "tab1text" title=" into mySpecialvariable
This would create error, double binary operator, so if you wanted to express data that contains operators, what would be the best way to handle this type of data? when you need to hold this data is there some kind of method of expressing this data without having to create a field to hold the data?
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: put xml string with quotes?

Post by Klaus »

Hi Thomas,

you need to write out the QUOTE! :-)
...
put QUOTE & "tab1text" & QUOTE && "title=" into mySpecialvariable
...

Or use my very handy fcuntion, that I use for this kind of stuff:

Code: Select all

function q tString
  return QUOTE & tString & QUOTE
end q
:-)
..
put q("tab1text") && "title=" into mySpecialvariable
...

For database work I also use a similar function for SINGLE quotes ' :

Code: Select all

function q2 tString
  return "'" & tString & "'"
end q2
Best

Klaus
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: put xml string with quotes?

Post by dunbarx »

If I understand at all, the way to create any string (including the ability to add double quotes to that string) is to concatenate little bits of text together:

put "tabText" && "title=" into myspecialVariable.

You sometimes have to parse the incoming data by hand, depending.

If this is at all pertinent, try this as well, just as an experiment:

put "tabText" && quote & "title=" & quote into myspecialVariable.

Craig Newman
ThomasBodetti
Posts: 16
Joined: Tue May 14, 2013 12:30 pm

Re: put xml string with quotes?

Post by ThomasBodetti »

Oh, yes thank you, gentleman, I appreciate the replies, this makes perfect sense, If I could only unlearn the old ways...

again thank you for the replies, it is much appreciatiated.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: put xml string with quotes?

Post by Klaus »

A votre service, monsieur! :D
Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: put xml string with quotes?

Post by Simon »

Ahh, just because I like my little stack here:
Attachments
infamous_quotes.zip
LC 6
(838 Bytes) Downloaded 340 times
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Post Reply