找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 23755|回复: 4

[文本处理] 批处理如何把XML中指定内容批量提取出来?

[复制链接]
发表于 2019-12-9 17:31:01 | 显示全部楼层 |阅读模式
网站地图只有XML的 。我想把XML里面的连接提取出来
        <url>
                <loc>https://m.hehgrwrld.net/info/8/8947.html</loc>
                <lastmod>2019-11-04</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.9</priority>
        </url>
        <url>
                <loc>https://m.hehgrwrld.net/info/9/9488.html</loc>
                <lastmod>2019-11-04</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.9</priority>
        </url>
        <url>
                <loc>https://m.hehgrwrld.net/info/10/10034.html</loc>
                <lastmod>2019-11-04</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.9</priority>
        </url>
        <url>
                <loc>https://m.hehgrwrld.net/info/5/5453.html</loc>
                <lastmod>2019-12-06</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.9</priority>
        </url>
        <url>
                <loc>https://m.hehgrwrld.net/info/17/17590.html</loc>
                <lastmod>2019-12-04</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.9</priority>
        </url>
        <url>
                <loc>https://m.hehgrwrld.net/info/18/18160.html</loc>
                <lastmod>2019-12-06</lastmod>
                <changefreq>daily</changefreq>
                <priority>0.9</priority>
        </url>
        <url>
                <loc>https://m.hehgrwrld.net/info/18/18201.html</loc>
                <lastmod>2019-12-06</lastmod>

我想把 https://m.hehgrwrld.net/info/18/18201.html 这样的连接单独提取出来。

不能提取XML的话我可以先复制到TXT。
发表于 2019-12-9 18:36:28 | 显示全部楼层
  1. @echo off
  2. for /f "tokens=3 delims=><" %%i in ('findstr /i /c:"https" "test.xml"') do echo %%i
  3. pause
复制代码
test.xml 换成你的xml文件
 楼主| 发表于 2019-12-9 19:47:29 | 显示全部楼层
回复 2# went

..然后怎么生成到TXT文本中呢,,,,
发表于 2019-12-9 20:03:50 | 显示全部楼层
回复 3# a8849516
  1. @echo off
  2. (for /f "tokens=3 delims=><" %%i in ('findstr /i /c:"https" "test.xml"') do echo %%i)>test.txt
  3. pause
复制代码
发表于 2019-12-11 10:56:05 | 显示全部楼层
  1. @echo off & rem title by author Gan

  2. ::保存为suad.txt(随意)
  3. for /f "tokens=3 delims=><" %%a in ('findstr "\<https://" suad.txt') do (>>result.txt echo %%a)

  4. pause & exit


复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-19 12:02 , Processed in 0.017253 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表