-1

在我看来,使用 XML 处理会比按顺序从文本文件中读取数据要慢。有人可以启发我吗?谢谢

4

1 回答 1

1

I don't know why you'd say one would be inherently faster or slower than the other.

A sequential file containing records would seem "flat" to me - one per table.

An XML file is hierarchical, which may include relationships between multiple tables. That logic would certainly mean more work to code and more CPU to execute, but it's also doing more than a simple sequential file would.

The answer, as it so often is, should be "it depends". Context is everything.

You're likely to use an XML schema that's as flat as a .csv.

XML parsers are standard stuff, so you don't have to write one. XML is self-describing - the tags are metadata. You can use schemas to validate XML. XML will be more verbose, because tags require bytes.

.csv can be handled by splitting each record at a delimiter of your choosing. You don't have tags, but you can send a header row. Validation is up to you and your parser implementation.

I'd say it's a wash.

于 2012-12-10T15:23:26.830 回答