×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

reading an xml file with GGI::Simple, with nested name/value pairs...

reading an xml file with GGI::Simple, with nested name/value pairs...

reading an xml file with GGI::Simple, with nested name/value pairs...

(OP)
here's an example:

CODE

<?xml version="1.0"?>
<RaceListResponse>
	<AccountType>User</AccountType>
	<AccountStatus>Enabled</AccountStatus>
	<RaceInfo>
		<RaceItem>
			<RaceLocation>98</RaceLocation>
			<RaceTime>10</RaceTime>
			<NumberOfRacers>24</NumberOfRacers>
			<RaceStops>
				<FoodItem>
					<FoodName>Op</FoodName>
					<FoodType>
						<a:string>1</a:string>
					</FoodType>
				</FoodItem>
				<FoodItem>
					<FoodName>Rt</FoodName>
					<FoodType>
						<a:string>2</a:string>
					</FoodType>
				</FoodItem>
			</RaceStops>
			<IdGroup>6</IdGroup>
		</RaceItem>
	</RaceInfo>
	<RaceStillLive>true</RaceStillLive>
</RaceListResponse> 

originally i was using the data pull, then i'm parsing the file using loops and arrays, but it's tidious and as the file gets more complex with information, i'm finding that this is probably the most inefficient way possible.

using CGI::Simple, or another module if my server supports it (i cannot add or change modules installed), i want to be able to import, then parse, then use the information.

any ideas? i know there is a lot of documentation online, but i'm in my second day and kind of burned out from my loops and arrays idea.

thanks!

- g

RE: reading an xml file with GGI::Simple, with nested name/value pairs...

Hi,

Quote:


originally i was using the data pull, then i'm parsing the file using loops and arrays, but it's tidious and as the file gets more complex with information, i'm finding that this is probably the most inefficient way possible.

With this in mind, I might suggest XML::Simple ( http://search.cpan.org/~grantm/XML-Simple-2.20/lib... ), simply because it will parse any XML structure into a Perl data structure from a single method call. However, it will likely require some fiddling around with the options available in order to return a suitable structure. Also, as you adjust the XML / depending on how, the structure returned may vary.

I would otherwise definitely consider looking into using XML::Twig ( http://search.cpan.org/~mirod/XML-Twig-3.42/Twig_p... ), my favorite XML parsing module.

Regards,

Chris

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close