2009/2/12 Qiang (James) <shijialee@gmail.com>:
> Felix New wrote:
>> hi,
>>
>>     各位, 最近在一个项目中需要解析xml, 想用SAX模式来处理, 但因为对XML处理的经验不多, 中间有几个问题不太清楚, 望大家帮解惑.
>>
>> 1. google以后, 发现可以用XML::SAX::ParserFactory解析, 用XML::SAX::Base来生成filter,
>> 来处理. 但因为SAX是基于事件的, 我要载取中间一段element, 有什么 tip? 比如下面一段,
>> 我想从原始xml中截到<body>之内的所有内容, how to ?
>>     <?xml version="1.0"?>
>>       <msg>
>>         <to>cl123</to>
>>         <type>event</type>
>>         <body>
>>           <info x="11111">some info</info>
>>           <other>info</other>
>>           <add>
>>             <foo x="sss"/>
>>           </add>
>>         </body>
>>       </msg>
>>
>> 2. 如果我的type有许多种的话, 是不是需要在filter判断每个start_element中的element的Name值,
>> 来判断?如果有多层嵌套, 那是不是需要有附加的数据结果来处理, 比如数据的push and pop, 来跟踪现在是在哪个element中?
>>
>> 3. validate
>>     对于schema的验证, 有没有与sax适用的方法/模块推荐?
>>
>>
>> Thanks!
>>
>
> 在其他有 XML 经验的朋友回答前,这些资源可能会有帮助:
>
> 社区里推荐的 Perl XML 模块
> http://www.perlfoundation.org/perl5/index.cgi?recommended_xml_modules
>
> 另外还有 Perl XML FAQ http://perl-xml.sourceforge.net/faq/
>
> Qiang(James)
>
> >
>
-- 
-------------------------------
                 ,,__
        ..  ..   / o._)
    /--'/--\  \-'||      riverlee(李江)   Email:riverlee2008@gmail.com
   /  perl   \_/ /     Harbin Medical University            Bioinfomatics
 .'\  \__\  __.'.'      Msn:riverlee2008@live.cn
   )\ |  )\ |            Blog:http://riverlee2008.blogspot.com
  // \\ // \\
 ||_  \\|_  \\_
    -' '--'' '--'
-------------------------------
--~--~---------~--~----~------------~-------~--~----~
您收到此信息是由于您订阅了 Google 论坛"PerlChina Mongers 讨论组"论坛。
 要在此论坛发帖,请发电子邮件到 perlchina@googlegroups.com
 要退订此论坛,请发邮件至 perlchina+unsubscribe@googlegroups.com
 更多选项,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问该论坛
-~----------~----~----~----~------~----~------~--~---
 
 
 
 博文
博文
 
 
没有评论:
发表评论