我目前有一个加密的XML文件,我将其解密并放入加密流中。然后我将其传递给使用DataTable.readxml的方法。 readxml()方法需要5-6秒,但我希望将其缩短到3-4秒。 (或更少)
有约90k条目。然后,我使用DataTable解析数据,最终使其成为gridview。我该怎么做才能提高性能?是否有任何调整XML,或者使用XML数据读取器进行迭代会产生更好的性能?
如果您知道不同的方法,请尽可能提供一些代码示例。
这是VB.Net代码:
Dim dt As New DataTable("Users")
dt.ReadXmlSchema(m_TheSchemaPath)
dt.ReadXml(m_datasetstream)
XML架构:
<?xml version="1.0" standalone="yes" ?>
- <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
- <xs:complexType>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element name="Users">
- <xs:complexType>
- <xs:sequence>
<xs:element name="displayname" type="xs:string" minOccurs="0" />
<xs:element name="samaccountname" type="xs:string" minOccurs="0" />
<xs:element name="department" type="xs:string" minOccurs="0" />
<xs:element name="telephonenumber" type="xs:string" minOccurs="0" />
<xs:element name="mail" type="xs:string" minOccurs="0" />
<xs:element name="l" type="xs:string" minOccurs="0" />
<xs:element name="physicalDeliveryOfficeName" type="xs:string" minOccurs="0" />
<xs:element name="objectGUID" type="xs:string" minOccurs="0" />
<xs:element name="givenname" type="xs:string" minOccurs="0" />
<xs:element name="initials" type="xs:string" minOccurs="0" />
<xs:element name="sn" type="xs:string" minOccurs="0" />
<xs:element name="facsimiletelephonenumber" type="xs:string" minOccurs="0" />
<xs:element name="mobile" type="xs:string" minOccurs="0" />
<xs:element name="pager" type="xs:string" minOccurs="0" />
<xs:element name="streetAddress" type="xs:string" minOccurs="0" />
<xs:element name="st" type="xs:string" minOccurs="0" />
<xs:element name="postalcode" type="xs:string" minOccurs="0" />
<xs:element name="company" type="xs:string" minOccurs="0" />
<xs:element name="msexchassistantname" type="xs:string" minOccurs="0" />
<xs:element name="title" type="xs:string" minOccurs="0" />
<xs:element name="telephoneassistant" type="xs:string" minOccurs="0" />
<xs:element name="extensionattribute10" type="xs:string" minOccurs="0" />
<xs:element name="othertelephone" type="xs:string" minOccurs="0" />
<xs:element name="homephone" type="xs:string" minOccurs="0" />
<xs:element name="ipphone" type="xs:string" minOccurs="0" />
<xs:element name="otherhomephone" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
以下是XML文件中的示例元素我使用“test”将数据删空:
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Users>
<displayname>test</displayname>
<samaccountname>test</samaccountname>
<department>test</department>
<telephonenumber>test</telephonenumber>
<mail>test</mail>
<l>test</l>
<physicalDeliveryOfficeName>test</physicalDeliveryOfficeName>
<objectGUID>test</objectGUID>
<givenname>test</givenname>
<initials>test</initials>
<sn>test</sn>
<facsimiletelephonenumber>test</facsimiletelephonenumber>
<streetAddress>test</streetAddress>
<st>test</st>
<company>test</company>
<title>test</title>
<employeeType>test</employeeType>
<destinationIndicator>test</destinationIndicator>
</Users>
<Users>
<displayname>test</displayname>
<samaccountname>test</samaccountname>
<department>test</department>
<telephonenumber>test</telephonenumber>
<mail>test</mail>
<l>test</l>
<physicalDeliveryOfficeName>test</physicalDeliveryOfficeName>
<objectGUID>test</objectGUID>
<givenname>test</givenname>
<initials>test</initials>
<sn>test</sn>
<facsimiletelephonenumber>test</facsimiletelephonenumber>
<streetAddress>test</streetAddress>
<st>test</st>
<postalcode>test</postalcode>
<company>test</company>
<msexchassistantname>test</msexchassistantname>
<title>test</title>
<extensionattribute10>test</extensionattribute10>
<othertelephone>test</othertelephone>
<homephone>test</homephone>
<employeeType>test</employeeType>
<destinationIndicator>test</destinationIndicator>
</Users>