抛开xml及其模块,  用regex 也可以做啊

( my  $data ) =  $string =~
/^\s*BLineCode><!\[CDATA\[(.*)\]\]><\/BLineCode>\s*$/m  ;


print $data ;





2011/3/11 DXX <[email protected]>

>
> hi:
>
> 我是一个perl程序员,最近遇到一个棘手的问题,我们有个脚本(解析XML文件)现在要用dom模块来进行解析,但是相关的文档太少了,我看了dom的源码,找了google还是没找到到底该怎么解决,所以希望路过的大神能够看到这个问题,并顺手解决一下:
>    XML文件是这样的:
>  <ScriptRule>
>     <Rule>
>       <BLineCode><![CDATA[JX-LINUX-TY-PZ-14-OPT]]></BLineCode>
>       <BLineName><![CDATA[Perl]]><<
> /BLineName>
>       <BLineDesc><![CDATA[]]></BLineDesc>
>       <BLineSeverity><![CDATA[1]]></BLineSeverity>
>       <IsCheck><![CDATA[1]]></IsCheck>
>       <RuleExpression><![CDATA[on remote_record it Match
> YES]]></RuleExpression>
>       <BLineValue><![CDATA[]]></BLineValue>
>       <Unit><![CDATA[]]></Unit>
>       <FormatRule><![CDATA[Linux]]></FormaatRule>
>       <Solution><![CDATA[]]></Solution>
>       <BLineStandard><![CDATA[1]]></BLineStandard>
>     </Rule>
> </ScriptRule>
>
> 我现在要将cdata进行解析,并放入一个哈希或者数组中:
> 形式像这样的:
> %hash =
> ("BLineCode"=>"JX-LINUX-TY-PZ-14-OPT"),或者是简单的告诉我要怎么把BLineCode和对应的cdata值取出来,不盛感激。
> 期待有个传说的人物出现,解决我这个问题
> --
> nothing is impossible to a willing heart
>
> --
> 您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。
> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
>



-- 
            Yours Sincerely
                    Zeng Hong

-- 
您收到此邮件是因为您订阅了 Google 网上论坛的“PerlChina Mongers 讨论组”论坛。
要向此网上论坛发帖,请发送电子邮件至 [email protected]。
要取消订阅此网上论坛,请发送电子邮件至 [email protected]。
若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。

回复