Gossamer Forum
Home : General : Perl Programming :

parsing xml >> html

Quote Reply
parsing xml >> html
I'm using a cgi script to parse an xml file and display it as html. Each data download consists of several records.

rec1 field1|rec1 field2|rec1 field3
rec2 field1|rec2 field2|rec2 field3

Unfortunately, if a record has an empty field, the field from the previous record is displayed.

rec3 field1|rec3 field2|rec2 field3

The error is obviously in the parsing of the file because when I download the raw xml file, the empty fields are displayed empty.

Can anyone help?
Thanks
Quote Reply
Re: [Alba] parsing xml >> html In reply to
Can you show us some code? There is not much anyone can do to help without the code. Did you roll your own XML parser or are you using something from CPAN like XML::Simple?

~Charlie
Quote Reply
Re: [Chaz] parsing xml >> html In reply to
Hi

I have come back to this problem again. See attached file.

Working with 6 fields.
Example:
If the field address3 is empty, the data is being taken from the previous record. (This is happening for all empty fields).

I do note that the empty fields, instead of being displayed as
<address3></address3>
are being displayed as <address3/>.

Is there some code I can add to the script that will recognise the <address3/> type xml tags as representing empty fields?

Many thanks.
Quote Reply
Re: [Alba] parsing xml >> html In reply to
I dunno how to do this but try to reset the value of address3 at beginning of each tag.

I found that to use XML::Simple is much simpler.

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] parsing xml >> html In reply to
Thanks.

Unfortunately I don't have XML::SIMPLE installed; have a script that does this very well.

Quote:
reset the value of address3 at beginning of each tag

How do I do this?
Quote Reply
Re: [Alba] parsing xml >> html In reply to
Please see the attached.

I did not test it yet but it should be working.

Cheers,

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [tandat] parsing xml >> html In reply to
That fixed it. I don't understand why, but that doesn't matter because the script now works properly.

Thank you.