xml引入另一个xml文件_什么是XML文件(以及如何打开一个XML文件)?

xml引入另一个xml文件

xml引入另一个xml文件

A file with the .xml file extension is an Extensible Markup Language (XML) file. These are really just plain text files that use custom tags to describe the structure and other features of the document.

扩展名为.xml的文件是可扩展标记语言(XML)文件。 这些实际上只是纯文本文件,使用自定义标签来描述文档的结构和其他功能。

什么是XML? (What is XML?)

XML is a markup language created by the World Wide Web Consortium (W3C) to define a syntax for encoding documents that both humans and machines could read. It does this through the use of tags that define the structure of the document, as well as how the document should be stored and transported.

XML是由万维网联盟(W3C)创建的一种标记语言,用于定义一种语法,用于对人类和机器均可读取的文档进行编码。 它通过使用定义文档结构的标签以及应如何存储和运输文档来实现此目的。

It’s probably easiest to compare it to another markup language with which you might be familiar—the Hypertext Markup Language (HTML) used to encode web pages. HTML uses a pre-defined set of markup symbols (short codes) that describe the format of content on a web page. For example, the following simple HTML code uses tags to make some words bold and some italic:

将它与您可能熟悉的另一种标记语言(用于编码网页的超文本标记语言(HTML))进行比较可能是最容易的。 HTML使用一组预定义的标记符号(短代码)来描述网页上内容的格式。 例如,以下简单HTML代码使用标记将一些单词加粗和斜体:

This is how you make <b>bold text</b> and this is how you make <i>italic text</i>

The thing that differentiates XML, though, is that it’s extensible. XML doesn’t have a predefined markup language, like HTML does. Instead, XML allows users to create their own markup symbols to describe content, making an unlimited and self-defining symbol set.

但是,区别XML的地方在于它是可扩展的。 XML没有HTML那样的预定义标记语言。 取而代之的是,XML允许用户创建自己的标记符号来描述内容,从而制作出无限制且自定义的符号集。

Essentially, HTML is a language that focuses on the presentation of content, while XML is a dedicated data-description language used to store data.

本质上,HTML是一种专注于内容表示的语言,而XML是一种用于存储数据的专用数据描述语言。

XML is often used as the basis for other document formats—hundreds, in fact. Here are a few you might recognize:

XML通常被用作其他文档格式的基础-实际上有数百种。 您可能会认识以下几个:

  • RSS and ATOM both describe how reader apps handle web feeds.

    RSS和ATOM都描述了阅读器应用如何处理Web feed。

  • Microsoft .NET uses XML for its configuration files.

    Microsoft .NET使用XML作为其配置文件。

  • Microsoft Office 2007 and later use XML as the basis for document structure. That’s what the “X” means in the .DOCX Word document format, for example, and it’s also used in Excel (XLSX files) and PowerPoint (PPTX files).

    Microsoft Office 2007和更高版本使用XML作为文档结构的基础。 例如,这就是.DOCX Word文档格式中“ X”的含义,并且还用于Excel(XLSX文件)和PowerPoint(PPTX文件)中。

So, if you have an XML file, that doesn’t necessarily tell you what app it’s intended for use with. And typically, you won’t need to worry about it, unless you’re the one actually designing the XML files.

因此,如果您有一个XML文件,则不一定告诉您打算使用哪个应用程序。 通常,您无需担心,除非您是真正设计XML文件的人。

我如何打开一个? (How Do I Open One?)

There are a few ways you can open an XML file directly. You can open and edit them with any text editor, view them with any web browser, or use a website that lets you view, edit, and even convert them to other formats.

您可以通过几种方法直接打开XML文件。 您可以使用任何文本编辑器打开和编辑它们,使用任何Web浏览器查看它们,或者使用可以查看,编辑甚至将它们转换为其他格式的网站。

如果您定期使用XML文件,请使用文本编辑器 (Use a Text Editor If You Work With XML Files Regularly)

Since XML files are really just text files, you can open them in any text editor. The thing is, a lot of text editors—like Notepad—just aren’t designed to show XML files with their proper structure. It might be okay for popping an XML file open and taking a quick look to help figure out what it is. But, there are much better tools for working with them.

由于XML文件实际上只是文本文件,因此您可以在任何文本编辑器中打开它们。 事实是,许多文本编辑器(如记事本)并不是为了显示具有适当结构的XML文件而设计的。 弹出一个XML文件并快速浏览一下以找出其含义可能是好的。 但是,还有很多更好的工具可以与他们合作。

Right-click the XML file you want to open, point to “Open With” on the context menu, and then click the “Notepad” option.

用鼠标右键单击要打开的XML文件,在上下文菜单上指向“打开方式”,然后单击“记事本”选项。

Note: We’re using Windows examples here, but the same holds true for other operating systems. Look for a good third-party text editor that is designed to support XML files.

注意:此处使用的是Windows示例,但其他操作系统也是如此。 寻找一个好的第三方文本编辑器,该编辑器旨在支持XML文件。

The file does open, but as you can see, it loses most of its formatting and crams the whole thing onto just two lines of the document.

该文件确实打开了,但是如您所见,它丢失了大部分格式,并将整个内容塞满了文档的两行。

So while Notepad might be useful for quickly checking out an XML file, you’re much better off with a more advanced tool like Notepad++, which highlights syntax and formats the file the way it’s intended.

因此,虽然Notepad可能对于快速检出XML文件很有用,但是使用更先进的工具(例如Notepad ++)会更好,它可以突出显示语法并按预期方式格式化文件。

Here is the same XML file opened in Notepad++:

这是在Notepad ++中打开的相同XML文件:

使用Web浏览器查看结构化数据 (Use a Web Browser to View the Structured Data)

If don’t really need to edit XML files, but just need to view them on occasion, the browser you’re using to read this article is well-suited to the job. And in fact, your default web browser is likely set up as the default viewer for XML files. So, double-clicking an XML file should open it in your browser.

如果确实不需要编辑XML文件,而只是偶尔需要查看它们,那么您用来阅读本文的浏览器非常适合此工作。 实际上,您的默认Web浏览器可能已设置为XML文件的默认查看器。 因此,双击XML文件应在浏览器中将其打开。

If not, you can right-click the file to find options for opening it with whatever app you want. Just select your web browser from the list of programs. We’re using Chrome in this example.

如果没有,您可以右键单击该文件以找到用于使用所需任何应用程序打开文件的选项。 只需从程序列表中选择您的Web浏览器。 在此示例中,我们使用的是Chrome。

When the file opens, you should see nicely-structured data. It’s not as pretty as the color-coded view you get with something like Notepad++, but it’s a far sight better than what you get with Notepad.

打开文件后,您应该会看到结构良好的数据。 它不如使用Notepad ++所获得的带有颜色编码的视图漂亮,但远比使用Notepad所获得的更好。

使用在线编辑器查看,编辑或转换XML文件 (Use An Online Editor to View, Edit, or Convert XML Files)

If want to edit the occasional XML file and don’t want to download a new text editor, or if you need to convert an XML file to another format, there are a few decent online XML editors available for free. TutorialsPoint.com, XMLGrid.net, and CodeBeautify.org all let you view and edit XML files. After you’ve done your editing, you can download the changed XML file, or even convert it to a different format.

如果要编辑偶发的XML文件并且不想下载新的文本编辑器,或者需要将XML文件转换为另一种格式,则有一些不错的在线XML编辑器免费提供。 TutorialsPoint.comXMLGrid.netCodeBeautify.org均允许您查看和编辑XML文件。 完成编辑后,您可以下载更改后的XML文件,甚至可以将其转换为其他格式。

For the example here, we’ll be using CodeBeautify.org. The page is divided into three sections. On the left is the XML file you’re working with. In the middle, you’ll find several options. On the right, you’ll see the results of some of the options you can select. For example, in the image below, our full XML file is on the left and the tree view is showing in the results pane because we clicked the “Tree View” button in the middle.

对于此处的示例,我们将使用CodeBeautify.org。 该页面分为三个部分。 左侧是您正在使用的XML文件。 在中间,您会找到几个选项。 在右侧,您将看到可以选择的某些选项的结果。 例如,在下图中,我们的完整XML文件位于左侧,并且树状视图显示在结果窗格中,因为我们单击了中间的“树状视图”按钮。

Here’s a better look at those options. Use the “Browse” button to upload an XML file from your computer or the “Load URL” button to pull XML from an online source.

这是对这些选项的更好看。 使用“浏览”按钮从计算机上载XML文件,或使用“加载URL”按钮从在线资源中提取XML。

The “Tree View” button displays your data in a nicely formatted tree structure in the results pane, with all your tags on the left in orange and the attributes to the right of the tags.

“树状视图”按钮在结果窗格中以格式正确的树结构显示数据,所有标签的左侧为橙色,标签的右侧为属性。

The “Beautify” displays your data in neat, easy-to-read lines in the results pane.

“美化”在结果窗格中以整洁,易于阅读的行显示您的数据。

The “Minify” button displays your data using the least amount of white space possible. It will attempt to put every single piece of data on one line. This comes in handy when trying to make the file smaller. It will save some space, but at the cost of being able to read it effectively.

“缩小”按钮使用尽可能少的空白显示您的数据。 它将尝试将每条数据放在一行上。 尝试使文件更小时,这很有用。 它将节省一些空间,但要以能够有效读取它为代价。

And finally, you can use the “XML to JSON” button to convert the XML to JSON format, the “Export to CSV” button to save your data as a comma-separated values file, or the “Download” button to download any changes you’ve made as a new XML file.

最后,您可以使用“将XML转换为JSON”按钮将XML转换为JSON格式,使用“导出为CSV”按钮将数据另存为逗号分隔的值文件,或使用“下载”按钮下载任何更改您已将其制作为新的XML文件。

翻译自: https://www.howtogeek.com/357092/what-is-an-xml-file-and-how-do-i-open-one/

xml引入另一个xml文件

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值