Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034
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
 
Hi,

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 ( ), 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 ( ), my favorite XML parsing module.

Regards,

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top