我的经验非常有限,所以想问一些关于如何处理我的要求的意见。
我有以下需要分析并放入XML的数据。对于我的第一次尝试,我使用TextFieldParser,很多CASE
语句和XMLWriter
来生成XML输出文件。它工作正常,但我确信必须有更好的方法来做到这一点。
正如您将在下面看到的那样,输入文件不是直接的,并且包含字符串和整数,并且根据第一列中的关键字,该行的其余部分具有特定含义。每一行都不同,我并不总是对每一列感兴趣。
此外,在某些情况下,可以重复某些行(或行块)。例如CLIENT,INCLUDE,SCHED等
对于我的第二次尝试,我已经开始使用XDocument
XElement
并在昨天的SO处得到了一些有价值的信息。我开始使用此功能,但在CASE
语句之间传出/或之间存在一些问题。
今天我读了另一篇文章,建议使用词典而不是CASE。人们可以在字典中加入一种方法,这似乎是一个有趣的想法。
有什么建议吗?
CLASS EIT_PX_UNIX_Adhoc *NULL* 0 760000 0 *NULL*
NAMES
INFO 0 0 0 0 *NULL* 0 0 60 0 0 0 0 0 0 0 1 0 0 1383584093
RES STU_PX_DD_pxddeit_files *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
POOL NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup NetBackup
FOE 0 0 0 0 0 0 0 0 0 0
SHAREGROUP *ANY*
DATACLASSIFICATION *NULL*
CLIENT 10.150.131.201 HP9000-700 HP-UX11.11 0 0 0 0 *NULL*
CLIENT pxhpc053 HP9000-700 HP-UX11.11 0 0 0 0 *NULL*
CLIENT prdrpxx027 HP9000-700 HP-UX11.11 0 0 0 0 *NULL*
CLIENT prdrpxx028 HP9000-700 HP-UX11.11 0 0 0 0 *NULL*
CLIENT prdrpxx029 HP9000-700 HP-UX11.11 0 0 0 0 *NULL*
CLIENT prdrpxx030 HP9000-700 HP-UX11.11 0 0 0 0 *NULL*
INCLUDE ALL_LOCAL_DRIVES
SCHED Full 0 1 604800 13 0 0 0 *NULL* 0 0 0 0 0 0 -1 0 0 0
SCHEDWIN 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SCHEDRES *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
SCHEDPOOL *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
SCHEDRL 13 1 1 1 1 1 1 1 1 1
SCHEDFOE 0 0 0 0 0 0 0 0 0 0
SCHEDSG *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
SCHED Incr 1 1 604800 13 0 0 0 *NULL* 0 0 0 0 0 0 -1 0 0 0
SCHEDWIN 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SCHEDRES *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
SCHEDPOOL *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
SCHEDRL 13 1 1 1 1 1 1 1 1 1
SCHEDFOE 0 0 0 0 0 0 0 0 0 0
SCHEDSG *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL* *NULL*
<Policy Number="5">
<PolicyName>EIT_PX_UNIX_Adhoc</PolicyName>
<General>
<FollowNFS>Disabled</FollowNFS>
<Compression>Disabled</Compression>
<Encryption>Disabled</Encryption>
<LimitJobsperPolicy>60</LimitJobsperPolicy>
<CrossMountPoints>Disabled</CrossMountPoints>
<Active>No</Active>
<CollectTIR>No</CollectTIR>
<MultipleDataStreams>Yes</MultipleDataStreams>
<CheckPointRestart>Enabled</CheckPointRestart>
<CheckPointRestartMinutes>15</CheckPointRestartMinutes>
<CollectBMR>Disabled</CollectBMR>
<Granular>Disabled</Granular>
<NoClientDirect>Disabled</NoClientDirect>
<UseAccelerator>Disabled</UseAccelerator>
<Residence>STU_NX_TAPE_pronbu21_SL8500</Residence>
<VolumePool>NetBackup</VolumePool>
<DataClassification>*NULL*</DataClassification>
<Residence>STU_PX_DD_pxddeit_files</Residence>
<VolumePool>NetBackup</VolumePool>
<DataClassification>*NULL*</DataClassification>
</General>
<Clients>
<Client Number="1">
<ClientHostname>10.150.131.201</ClientHostname>
<ClientHardware>HP9000-700</ClientHardware>
<ClientOS>HP-UX11.11</ClientOS>
<ClientPriority>0</ClientPriority>
</Client>
</Clients>
<Clients>
<Client Number="2">
<ClientHostname>pxhpc053</ClientHostname>
<ClientHardware>HP9000-700</ClientHardware>
<ClientOS>HP-UX11.11</ClientOS>
<ClientPriority>0</ClientPriority>
</Client>
</Clients>
<Clients>
<Client Number="3">
<ClientHostname>prdrpxx027</ClientHostname>
<ClientHardware>HP9000-700</ClientHardware>
<ClientOS>HP-UX11.11</ClientOS>
<ClientPriority>0</ClientPriority>
</Client>
</Clients>
<Clients>
<Client Number="4">
<ClientHostname>prdrpxx028</ClientHostname>
<ClientHardware>HP9000-700</ClientHardware>
<ClientOS>HP-UX11.11</ClientOS>
<ClientPriority>0</ClientPriority>
</Client>
</Clients>
<Clients>
<Client Number="5">
<ClientHostname>prdrpxx029</ClientHostname>
<ClientHardware>HP9000-700</ClientHardware>
<ClientOS>HP-UX11.11</ClientOS>
<ClientPriority>0</ClientPriority>
</Client>
</Clients>
<Clients>
<Client Number="6">
<ClientHostname>prdrpxx030</ClientHostname>
<ClientHardware>HP9000-700</ClientHardware>
<ClientOS>HP-UX11.11</ClientOS>
<ClientPriority>0</ClientPriority>
</Client>
</Clients>
<IncludeList>
<Include>ALL_LOCAL_DRIVES </Include>
</IncludeList>
</Policy>