[英]Fastest Way of reading XML
I have an XML file in which I store data about a list of persons and another one in which I store a list of objects like this. 我有一个XML文件,其中存储了有关人员列表的数据,而另一个文件中则存储了这样的对象列表。
people.xml people.xml
<People>
<Person>
<Name>itsName</Name>
<Age> itsAge </Age>
<RecentAcquisitions>
<Acquisition>
<name>Apple</name>
<quantity>5</quantity>
</Acquisition>
</RecentAcquisitions>
</Person>
</People>
objects.xml objects.xml
<Objects>
<Object>
<Name>Apple</Name>
<Description>Fresh Apple</Description>
<Price>10</Price>
<etc>..lots of attributes..</etc>
</Object>
</Objects>
What is the most efficient way of extracting information from objects.xml based on the person Acquisition List at the runtime? 在运行时基于人员获取列表从object.xml中提取信息的最有效方法是什么? (in example the person should have 5 objects of type "Apple").
(例如,该人应具有5个“ Apple”类型的对象)。
Momentarily I use a solution which consists of storing each object from objects.xml in a list and when I'm loading a person I search for the respective object based on Acquisition->Name and add it in the person.AquisitionList; 我暂时使用一种解决方案,其中包括将来自object.xml的每个对象存储在一个列表中,并且在加载人员时,我会基于Acquisition-> Name搜索相应的对象并将其添加到person.AquisitionList;中。
Is there another way of doing this? 还有另一种方法吗?
Maybe I misunderstood the XML role but it feels wrong to store the information from an XML file in a list or array at runtime. 也许我误解了XML角色,但是在运行时将XML文件中的信息存储在列表或数组中感觉不对。
to my knowledge, using the runtime memory instead of constant read-write operations is the best way to do it / what you're doing is the right way. 据我所知,使用运行时内存而不是恒定的读写操作是最好的方法/您所做的就是正确的方法。
XML can be seen as 2 things: XML可以看作两件事:
1 - A way to store information, much like a database, until it needs to be retrieved for processing at runtime 1-一种类似于数据库的信息存储方式,直到需要在运行时对其进行检索以进行处理
this is what you are doing now... you store the objects list on disk using XML, and then you retrieve it for processing/load it into memory at runtime. 这就是您现在正在做的...使用XML将对象列表存储在磁盘上,然后在运行时检索它进行处理/将其加载到内存中。
2 - A standardized way of passing information around, regardless of technology. 2-无论技术如何,传递信息的标准化方式。
XML can be read in a multitude of languages and any language that can read a string can technically read and extract the data from an XML document. 可以使用多种语言读取XML,并且任何可以读取字符串的语言都可以从技术上读取XML文档并从中提取数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.