XML Processing
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
XML Processing
Hi,
I am working with XML at the moment (I hate XML by the way) and I have hit an issue with trying to parse out a value that has a period in it...
The XML Data looks like this (example)
<?xml version="1.0" encoding="UTF-8"?>
<day-entries type="array">
<day-entry>
<adjustment-record type="boolean">false</adjustment-record>
<created-at type="datetime">2013-07-01T23:14:16Z</created-at>
<hours type="decimal">0.3</hours>
The value I am trying to parse out is the "hours" tag.
I am using the below code to parse but only get returned the "0." not the "0.3"
Any ideas as to why it only returns the data before the period?
put revXMLNodeContents(tXMLEntries, "day-entries/day-entry/hours") after tCurrentProjectNameList
I am working with XML at the moment (I hate XML by the way) and I have hit an issue with trying to parse out a value that has a period in it...
The XML Data looks like this (example)
<?xml version="1.0" encoding="UTF-8"?>
<day-entries type="array">
<day-entry>
<adjustment-record type="boolean">false</adjustment-record>
<created-at type="datetime">2013-07-01T23:14:16Z</created-at>
<hours type="decimal">0.3</hours>
The value I am trying to parse out is the "hours" tag.
I am using the below code to parse but only get returned the "0." not the "0.3"
Any ideas as to why it only returns the data before the period?
put revXMLNodeContents(tXMLEntries, "day-entries/day-entry/hours") after tCurrentProjectNameList
Re: XML Processing
Anyone got some idea's???
I can get any of the other tags sucessfully that dont have a period in the value...
I can get any of the other tags sucessfully that dont have a period in the value...
Re: XML Processing
Replace?
Sure it's a workaround
Simon
Sure it's a workaround

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: XML Processing
I suppose I could try that...Maybe something like replacing the period with a comma, need to keep something there to
determine actual correct number (0.3 as apposed to 30.03)
repeat with x = the number of lines of tXMLVar down to 1
if "hours" is among the text of line x of tXMLVar then
replace "." with comma
end if
end repeat
determine actual correct number (0.3 as apposed to 30.03)
repeat with x = the number of lines of tXMLVar down to 1
if "hours" is among the text of line x of tXMLVar then
replace "." with comma
end if
end repeat
Re: XML Processing
Code: Select all
replace "." with comma in line x of tXMLVar
Too bad its a workaround. I hope someone around here knows better, seems to be something common, having a decimal point.
I got a question Kia, do you think it would have been better for me not to have replied to your posting? It could be that sometimes if a post has an answer (right or wrong) people who know the correct answer might not bother looking at it?
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: XML Processing
Thanks Simon,
Its funny you ask that question as in my opinion LiveCode is all about not having the correct answer but providing a solution.
I often reply back to posts with a work around and in my opinion that is the power and prupose of a Forum.
If someone is looking for only answers, use stackOverflow
Its funny you ask that question as in my opinion LiveCode is all about not having the correct answer but providing a solution.
I often reply back to posts with a work around and in my opinion that is the power and prupose of a Forum.
If someone is looking for only answers, use stackOverflow
Re: XML Processing
Nice!If someone is looking for only answers, use stackOverflow
I was wondering what a difference could be.
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: XML Processing
Turns out there was a weird error in my code that caused this...
Very long story to fully explain but my code was actually modifying the data before parsing out the result
Very long story to fully explain but my code was actually modifying the data before parsing out the result