We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › loadStrings(url) . breaking at <p> tags in text
Page Index Toggle Pages: 1
loadStrings(url) . breaking at <p> tags in text (Read 643 times)
loadStrings(url) . breaking at <p> tags in text
Jun 27th, 2008, 5:47pm
 
hi
i am trying to get values from a database into processing using loadstring(url).
but somehow all the integer or float data does not come into processign even though it was echoed in php page.

does anyone have any idea?
i am breaking each row of data using newline character and each coloumn using RAM_BREAK

http://turing.lecolededesign.com:16080/~rshukla/gui_feed.php

String [] feeds;
String [] elements;

void setup()
{
 background(255,255,255);
 String url = "http://turing.lecolededesign.com:16080/~rshukla/gui_feed.php";
 feeds = loadStrings(url);
 //println(position);
 //String[] links = split(position[0], "RK_BREAK");
 for (int i = 0; i < feeds.length; i++)
 {
 String [] elements=split(feeds[i], "RAM_BREAK");
 for (int j = 0; j < elements.length; j++)
 {
 println(elements[j]);
 println(j);
 println("\n");
 }
 //println(elements.length);
}
}

void draw()
{

}
Re: loadStrings(url) . does not return integer
Reply #1 - Jun 27th, 2008, 5:53pm
 
There's far too much data in that page to work out what exactly the problem is unfortunately. Are you saying that there's data missing form the stuff in the Strings, or that you're unable to convert from a string like "foo bar 123 baz" into a string and the integer value 123?

You have to bear in mind that "123" doesn't equal 123
Re: loadStrings(url) . does not return integer
Reply #2 - Jun 27th, 2008, 5:57pm
 
yes there is data missing
it is showing attributes that are non integer non float .
those which are interger or float , they are echoed by php in browser
but they are not received in processing

so are there are any clues to as where is the problem
Re: loadStrings(url) . does not return integer
Reply #3 - Jun 27th, 2008, 6:45pm
 
It's ok here. All integers and html code strings are correctly parsed. So... can you tell us more precisely where the problem is? Which element is not in the resulting array?
Re: loadStrings(url) . does not return integer
Reply #4 - Jun 30th, 2008, 11:09am
 
I have got the problem source
my database has feeds elements stored in it .
In the content field of the feeds, there are <p> tags and the loadstring is breaking the text at these tags.

so any piece of text between <p> and </p> becomes a new feed in itself.

Any idea how to correct this?
Re: loadStrings(url) . breaking at <p> tags
Reply #5 - Jun 30th, 2008, 12:31pm
 
loadStrings won't break the feeds at a <p> tag, it doesn't understand tags at all. It does break the data up at newlines though, so each line is a separate string in the array.

If you want all your data in a single String, then there needs to be no newlines in it.
Page Index Toggle Pages: 1