Click here to get back home

Extracting value from data within an element.

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Extracting value from data within an element. anthony 11-30-2005
Posted by anthony on November 30, 2005, 5:26 am
Please log in for more thread options


Hello forum.

I have written a perl script that will parse XML files and extract
certain elements and put them into a comma delimited file. This works
no problem. What I have encountered however, is that in one of my XML
files, there is a piece of information that I would like to extract
that is emebedded in the data. I am not sure if any of the options in
XML::Parser or XML::Simple modules will allow me to do this. The
element name and data of the XML file is shown below. What I would like
to do is extract the number from this data.

<desc>Sun(sm) Alert Notification 45707: Buffer overflow in
vold(1M)</desc>

next element:

<desc>Sun(sm) Alert Notification 45240: he "/proc/[pid]/sigact" File
May Contain Sensitive Data</desc>

Anyone have any ways to do this?



Posted by Eric J. Roode on December 1, 2005, 6:12 am
Please log in for more thread options


@g49g2000cwa.googlegroups.com:

[...]
> no problem. What I have encountered however, is that in one of my XML
> files, there is a piece of information that I would like to extract
> that is emebedded in the data. I am not sure if any of the options in
> XML::Parser or XML::Simple modules will allow me to do this. The
> element name and data of the XML file is shown below. What I would like
> to do is extract the number from this data.
>
> <desc>Sun(sm) Alert Notification 45707: Buffer overflow in
> vold(1M)</desc>
>
> next element:
>
> <desc>Sun(sm) Alert Notification 45240: he "/proc/[pid]/sigact" File
> May Contain Sensitive Data</desc>
>
> Anyone have any ways to do this?

That is not a function of XML parsing; that is a pattern-matching problem.
Extract the <desc> contents into a string, then use a regex on it.

--
Eric
`$=`;$_=\%!;($_)=/(.)/;$==++$|;($.,$/,$,,$\,$",$;,$^,$#,$~,$*,$:,@%)=(
$!=~/(.)(.).(.)(.)(.)(.)..(.)(.)(.)..(.)......(.)/,$"),$=++;$.++;$.++;
$_++;$_++;($_,$\,$,)=($~.$"."$;$/$%[$?]$_$$,$:$%[$?]",$"&$~,$#,);$,++
;$,++;$^|=$";`$_$$,$/$:$;$~$*$%[$?]$.$~$*$$%[$?]$;$$"$^$~$*.>&$=`


Similar ThreadsPosted
CPAN not extracting documentation August 8, 2005, 6:28 pm
newbie extracting same text from earch results October 7, 2005, 7:46 pm
PDF::API2 - Extracting text and position from PDF file April 17, 2008, 9:20 am
How to text in HTML::Element October 23, 2004, 7:31 pm
How to *modify* text in HTML::Element October 23, 2004, 8:16 pm
perl xml check for element closure November 18, 2006, 9:26 pm
XML::LibXSLT element tags stripped out of transformation March 21, 2005, 6:32 pm
HTML::Element->right/->look_down lose, I need to walk the tree June 20, 2005, 9:56 am
manually expire an element in Memoize (also on comp.lang.perl.misc) February 14, 2007, 5:52 pm
Extracting strings delimited by other strings May 7, 2005, 11:54 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap