读 XML 文件和 写 XML 文件- 通过JAXB 实现

读取 XML 文件与生成 XML 文件- Java 实现读取 XML 文件测试文件生成对应的 xsd 文件xsd 文件内容读取 XML 文件测试文件<?xml version="1.0" encoding="UTF-8" ?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns...
摘要由CSDN通过智能技术生成

读 XML 文件

测试文件

test.xml

<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
        xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/">
    <url>
        <loc>http://m.example.com/index.html</loc>
        <mobile:mobile type="mobile"/>
        <lastmod>2009-12-14</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>http://www.example.com/index.html</loc>
        <lastmod>2009-12-14</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>http://www.example.com/autoadapt.html</loc>
        <mobile:mobile type="pc,mobile"/>
        <lastmod>2009-12-14</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
    <url>
        <loc>http://www.example.com/htmladapt.html</loc>
        <mobile:mobile type="htmladapt"/>
        <lastmod>2009-12-14</lastmod>
        <changefreq>daily</changefreq>
        <priority>0.8</priority>
    </url>
</urlset>

生成对应的 xsd 文件

xsd 文件内容

test.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.baidu.com/schemas/sitemap-mobile/1/" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9">
  <xs:import namespace="http://www.baidu.com/schemas/sitemap-mobile/1/" schemaLocation="mobile.xsd"/>
  <xs:element name="urlset">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值