免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3488 | 回复: 1
打印 上一主题 下一主题

怎么通过url地址获得xml网页的源码,再解析xml文件?? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-04-18 10:44 |只看该作者 |倒序浏览
本帖最后由 shahuala 于 2012-04-18 10:46 编辑

有个模块xml::simple是解析xml文件的,但是我现在要通过url得到xml文件,不知道怎么得到。用lwp::simple的get()的话我试过了是得到html格式的,和xml文件格式不符的,我的xml网页的源码是类似这种的:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="resources/xsl/ValidateInternals.xsl"?>
<ValidateInternals host="phx7b02c-15ava46zf8s/10.86.92.178" client-ip="10.254.68.12" xmlnssi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="resources/xsd/ValidateInternals.xsd" more-info="HeaderPH"><HeaderPH value="ool name: offer-app"></HeaderPH><HeaderConfig name="Configuration" desc="Configuration" href="ViewConfigCategoryList"></HeaderConfig><HeaderConfig name="ComponentStatus" desc="Component Status" href="ComponentStatusList"></HeaderConfig><HeaderConfig name="artnerContingency" desc="artner Contingency" href="artnerContingency"></HeaderConfig><HeaderConfig name="ServiceClientStatus" desc="Service Client Status" href="ValidateInternals?component=serviceclientstatus"></HeaderConfig><HeaderConfig name="V4MonitoringHub" desc="resentation" href="V4MonitoringHub"></HeaderConfig><HeaderConfig name="BusinessEventsConsole" desc="Business Events Console" href="BESConsole"></HeaderConfig><HeaderConfig name="NioAsyncSvcClientStatus" desc="NIO Service Client Status" href="ValidateInternals?component=NioAsyncSvcClientStatus"></HeaderConfig><Logs><![CDATA[http://logs.ebay.com/swat/file?r ... c%24%5cv3app%5Ccore]]> isProd="true"</Logs><CAL><![CDATA[http://10.2.179.17/cgi/logview?p ... tratus.phx.ebay.com]]></CAL><Component name="ersistedDataSources" alias="persisteddatasources" status="Created"><ersistedDataSources><Source><![CDATA[c:\ebayconfig\dsc\core\dsimport.xml (2012-04-13_16:30:2, DscInfo: version=55, checksum=56078, created=2012-04-13_16:20:15, modified=2012-04-13_16:20:15, dbenv=prod, deplslot=CORE, dnsregion=PHX, pool=v3offer, hwtype=, host=phx7b02c-15ava46zf8s]]></Source><ersistedConnPoolConfig><Name><![CDATA[CORE_acc]]></Name><User><![CDATA[misc2_app]]></User><URL><![CDATA[jdbcracle:thinmisc2.vip.ebay.com:1521:MISC2]]></URL><MinPoolSize>0</MinPoolSize><MaxPoolSize>6</MaxPoolSize><ConnectionTimeout>1</ConnectionTimeout><IdleTimeout>600</IdleTimeout><OrphanTimeout>30</OrphanTimeout><MaxStmtCacheSize>83</MaxStmtCacheSize><IdleStmtTimeout>620</IdleStmtTimeout><AutoFlushType>Default</AutoFlushType><ConnRateThrottle>0</ConnRateThrottle><DriverType>sql</DriverType><ConnectionProperties><!

我把它保存为.xml文件后还是不能解析出来,但是如果是这样的
<opt>
    <user login="grep" fullname="Gary R Epstein" />
    <user login="stty" fullname="Simon T Tyson" >
        <session pid="12345"/>
    </user>
    <text>This is a test.</text>
</opt>
就可以解析为哈希,请教各位大侠了

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
2 [报告]
发表于 2012-04-18 13:30 |只看该作者
“通过url得到xml文件”?web service?

use HTTP::Request;
use LWP::UserAgent;
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP