Advertisements

"zeelani" <> wrote:
> But if I have
> <Hotel>Marriott</Hotel><br>
> I am not sure how to read "Marriott" in perl. Does anyone have any
> ideas?

Yes, the part between the elements is char data, so what you can do is
create a global buffer, make it grow with char data, in the start tag you
reset the buffer, and in the end tag you check the name of it (Hotel), and
if it's the right one, in the start buffer should be the data (Marriot).

Note that char data can come in bursts, hence you need a global buffer
that you *add* to (not assign to).

Advertisements

Guest

zeelani wrote:
> But if I have
> <Hotel>Marriott</Hotel><br>
> I am not sure how to read "Marriott" in perl. Does anyone have any

It's easy to do this with XML::Simple (my parser of choice) for either
type of data (of course, the structure of the data is completely
different, because the input data is completely different). Observe the
results of this script upon both types of input data:

#!/usr/bin/perl
use strict; use warnings;
use Data:umper::Simple;
use XML::Simple;

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!