Oh, and don't forget to check for the trailing tags i.e. the </report> etc.
"Jeremy Reed" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Well, to do this you'll just have to write a loop that takes in every > <identifier>=<value> pair and converts them into an array of values attached > to the tag name. You'll have to parse the input character by character. > The following pseudo code might help to explain a bit: > > // input[x] refers to the character at position x in the string input > > > input = "<report gmt_date="1206082001" > unix_date="992001907.000000"></report>"; > > for (x = 0, x is each character in input) { > > if (input[x] equals "<") { > $tagname = getName(x); // returns the tag name, will stop at first white > space > for (y = x, y is each character in input beginning at pos x) { > if (input[y] equals " ") { > continue; //skips white space > } else if (input[y] equals "=") { > $value = getValue(y); //returns value beginning and ending with > quotes > addToArray($tagname, $paramname, $value); //adds the parsed values > to an array > } else { > $paramname = getParam(y); // returns param name up to whitespace or > '=' sign. > } > } > } > > > "Php Dood" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > I'm trying to figure out how to parse an xml document, and convert it into > > html... > > i know how to parse in simple xml stuff for example > > <easy>easy</easy> is pretty easy to parse in, and i know how to code that, > > but when you start adding flags that i'm going to need variables for, > > example <easy does="1" it="2">easy</easy> is not so easy. > > > > *** > > paste sample xml > > *** > > <report gmt_date="1206082001" unix_date="992001907.000000"> > > > > <location city="11531"> > > <forecast day_sequence="1" day_of_week="6" daylight="D" > > date="060801" high_temp="24.78" low_temp="14.51" sky_desc="3" > > precip_desc="*" temp_desc="8" air_desc="*" uv_index="7" > > wind_speed="18.51" wind_dir="270" humidity="48" dew_point="12.01" > > comfort="25.28" rainfall="*" snowfall="*" precip_prob="0" icon="2" /> > > <forecast day_sequence="2" day_of_week="7" daylight="D" > > date="060901" high_temp="20.34" low_temp="13.68" sky_desc="1" > > precip_desc="*" temp_desc="7" air_desc="20" uv_index="7" > > wind_speed="18.51" wind_dir="270" humidity="57" dew_point="9.23" > > comfort="19.23" rainfall="*" snowfall="*" precip_prob="2" icon="1" /> > > <forecast day_sequence="3" day_of_week="1" daylight="D" > > date="061001" high_temp="20.35" low_temp="12.01" sky_desc="3" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="56" dew_point="9.80" > > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > > <forecast day_sequence="4" day_of_week="2" daylight="D" > > date="061101" high_temp="20.34" low_temp="12.02" sky_desc="3" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="57" dew_point="10.34" > > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > > <forecast day_sequence="5" day_of_week="3" daylight="D" > > date="061201" high_temp="22.01" low_temp="13.12" sky_desc="3" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="55" dew_point="11.45" > > comfort="*" rainfall="*" snowfall="*" precip_prob="1" icon="2" /> > > <forecast day_sequence="6" day_of_week="4" daylight="D" > > date="061301" high_temp="23.12" low_temp="13.12" sky_desc="7" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="46" dew_point="9.79" > > comfort="*" rainfall="*" snowfall="*" precip_prob="2" icon="2" /> > > <forecast day_sequence="7" day_of_week="5" daylight="D" > > date="061401" high_temp="23.12" low_temp="13.68" sky_desc="7" > > precip_desc="*" temp_desc="7" air_desc="*" uv_index="7" > > wind_speed="*" wind_dir="*" humidity="49" dew_point="10.34" > > comfort="*" rainfall="*" snowfall="*" precip_prob="3" icon="2" /> > > </location> > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]