Re: parsing to XML
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 6 Oct 2005 10:20:15 GMT
<steeve_dun@xxxxxxxxxxxx> wrote in comp.lang.perl.misc:
> Hi everybody,
> I have a document that includes definitions.
> What I want is parsing the document and saving these definitions in a
> xml document.
> Is there a simple way to do so?
> Thank you!
>
> Example:
> #### beginning of ducument ####
> \glossary{HTML} {HyperText Markup Language} is the lingua franca for
> publishing hypertext on the \glossary {WWW}{World Wide Web}
> #### end of ducument ####
Your example doesn't show the variability of the data. Examples never
do, they only ever give a lower bound. There can always be a variant
that doesn't happen to appear in the example.
Can a "definition" span lines? Assuming that it can, you can't process
the text line-wise without major trickery. You'll need all of it in
memory . Here is a method that extracts the definitions from the text
and puts them in a hash:
my $text = <<'END_TEXT';
\\glossary{HTML} {HyperText Markup Language} is the lingua franca for
publishing hypertext on the \\glossary {WWW}{World Wide Web}
END_TEXT
my %definition_for = $text =~ /\\glossary\s*{([^}]*)}\s*{([^}]*)}/g;
Generating XML from the hash is probably a job for one of the XML modules.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- Follow-Ups:
- Re: parsing to XML
- From: steeve_dun
- Re: parsing to XML
- References:
- parsing to XML
- From: steeve_dun
- parsing to XML
- Prev by Date: FAQ 7.1 Can I get a BNF/yacc/RE for the Perl language?
- Next by Date: Re: Hidden overload and It is a better ways to save to Mysql, it is?
- Previous by thread: parsing to XML
- Next by thread: Re: parsing to XML
- Index(es):
Relevant Pages
|