首先,我打开了 TextEdit。转到格式菜单并设置选项-> 制作纯文本,我输入了以下数据,这是我的应用程序中所必需的。
<?xml version="1.0" encoding="ISO-8859-1"><tips><Prop_Tips><Tip_ID><![CDATA[1]]></Tip_ID><Category_ID>1</Category_ID><Tip_Title>Play Your Shot</Tip_Title><Tip_Thumb>http://192.168.32.212/jalpesh/igolf/TipThumb/PlayyrshotThumb.jpg</Tip_Thumb><Tip_image>http://192.168.32.212/jalpesh/igolf/TipImage/Playyrshot.jpg</Tip_image><Tip_Description>Every golfer likes to hit the ball long, high and straight, but experience tells you that you can expect a certain pattern to your shots.</Tip_Description><Category_Name>Course Management/Strategy</Category_Name></Prop_Tips><Prop_Tips><Tip_ID><![CDATA[2]]></Tip_ID><Category_ID>1</Category_ID><Tip_Title>Shots Curve From Sidehill Lies</Tip_Title><Tip_Thumb>http://192.168.32.212/jalpesh/igolf/TipThumb/Shots-Curve-From-Sidehill-LiesThumb.jpg</Tip_Thumb><Tip_image>http://192.168.32.212/jalpesh/igolf/TipImage/Shots-Curve-From-Sidehill-Lies.jpg</Tip_image><Tip_Description>Sidehill fairway lies will cause the ball to curve, slice right or hook left. Here's a tip to help make better contact.</Tip_Description><Category_Name>Course Management/Strategy</Category_Name></Prop_Tips></tips>
Run Code Online (Sandbox Code Playgroud)
将此文件保存为 UTF-8 后,每当我尝试通过 XMLParser 读取我的 XML 文件时,我都会从文件中获取以下数据
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf460
{\fonttbl\f0\fmodern\fcharset0 Courier-Bold;}
{\colortbl;\red255\green255\blue255;}
\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\pard\tx480\tx960\tx1440\tx1920\tx2400\tx2880\tx3360\tx3840\tx4320\tx4800\tx5280\tx5760\tx6240\tx6720\tx7200\tx7680\tx8160\tx8640\tx9120\tx9600\tx10080\tx10560\tx11040\tx11520\tx12000\tx12480\tx12960\tx13440\tx13920\tx14400\tx14880\tx15360\tx15840\tx16320\tx16800\tx17280\tx17760\tx18240\tx18720\tx19200\tx19680\tx20160\tx20640\tx21120\tx21600\tx22080\tx22560\tx23040\tx23520\tx24000\tx24480\tx24960\tx25440\tx25920\tx26400\tx26880\tx27360\tx27840\tx28320\tx28800\tx29280\tx29760\tx30240\tx30720\tx31200\tx31680\tx32160\tx32640\tx33120\tx33600\tx34080\tx34560\tx35040\tx35520\tx36000\tx36480\tx36960\tx37440\tx37920\tx38400\tx38880\tx39360\tx39840\tx40320\tx40800\tx41280\tx41760\tx42240\tx42720\tx43200\tx43680\tx44160\tx44640\tx45120\tx45600\tx46080\tx46560\tx47040\tx47520\tx48000\ql\qnatural\pardirnatural
\f0\b\fs24 \cf0 \CocoaLigature0 <?xml version="1.0" encoding="ISO-8859-1"?>\
<tips><Prop_Tips><Tip_ID><![CDATA[1]]></Tip_ID><Tip_Title>Play Your …Run Code Online (Sandbox Code Playgroud) IE7 取消选中该框的选项tools/content/settings不再适合我,这很奇怪。
有没有人对如何在 IE、FF3 或 Chrome 中查看未格式化的 XML 有任何其他想法?(好像肯定有FF插件,但是好像找不到)
<?xml version="1.0" encoding="UTF-8"?>
<!--Generated by octalforty Exile 1.7-->
<!--Copyright (C) 2004 octalforty studios. All rights reserved.-->
<configuration>
<configurationGeneral showPassword="1" maintainFileAssociations="1" enableHotKeys="1" minimizeToTray="1"/>
<configurationStorage createBackup="0" autoSave="0" shellOpenReadOnly="0" reloadLastStorage="1" lastStorage="C:\Users\me\Desktop\OctilePasswordfile.pws" reloadReadOnly="0"/>
<configurationSmartType smartType="0" smartTypeModifier="0" smartTypeVKey="0"/>
<configurationSorting autoSort="0" autoSortOrder="1"/>
<configurationClipboard eraseClipboard="0" eraseClipboardTimeout="0"/>
<configurationPasswordGenerator decimalDigits="0" lowercaseCharacters="0" punctuationMarks="0" specialCharacters="0" uppercaseCharacters="0" passwordLength="0"/>
<configurationHashGenerator hashOptions="0"/>
<configurationExportToXml exportFlags="0" exportFileName=""/>
</configuration>
Run Code Online (Sandbox Code Playgroud) 我需要从源读取数据,并且必须使用 shell 脚本形成一个 XML 文件。但首先我不知道如何使用 shell 脚本在文件中编写多行
我已经将打开.webloc文件的默认应用程序更改为 Firefox(使用RCDefaultApp,不错的套件,那个),这一切都很好,除了有点奇怪。如果我.webloc使用脚本创建一个(我正在使用从这个脚本改编的 Perl 脚本来创建可聚焦搜索的书签),那么它会在 Firefox 中打开为一些无样式的 XML(带有“这个 XML 文件似乎没有与它相关的任何样式信息。文档树显示在下面”标题)。
现在奇怪的是:如果我将一个 URL 从 Firefox URL 栏中拖到桌面上,我会得到一个.webloc由 Firefox 打开的文件,没有任何问题 - 但是当我查看内容时,它与我使用脚本创建的内容完全相同. 它必须与文件创建者有关 - 如果我打开 Firefox 创建的.webloc文件,然后从文本编辑器中保存它,它就不再有效。
发生什么了?两个相同的 XML 位如何根据它们的创建方式以不同的方式打开?有什么神奇的地方我可以改变吗?
作为参考,这里是.webloc由我的脚本创建的文件的内容(我也放置了由 Firefox 创建的文件,但由于它完全相同(我使用 diff 进行了检查),因此没有意义):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>http://www.spacetelescope.org/</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)