我有一个XML文件,其中包含1)序列化对象和2)序列化哈希表。这是我的伪xml文件(data.xml):
IDD_PROGRESSBAR DIALOGEX 0, 0, 369, 105
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Будь-ласка, зачекайте!"
FONT 8, "Microsoft Sans Serif", 400, 0, 0x1
BEGIN
CONTROL "",IDC_PROGRESS1,"msctls_progress32",PBS_MARQUEE | WS_BORDER,7,47,355,14
LTEXT "Триває обмін даними з опціональною платою! НЕ ВИМИКАЙТЕ РАДІОСТАНЦІЮ",IDC_STATIC,25,19,267,8
PUSHBUTTON "Примусово завершити роботу",IDC_BUTTON1,101,84,118,14
END
我的目标是将一半XML文件(最多为“AllowChangeStartMenuFolderName”)反序列化为“Information”对象,将剩余部分反序列化为哈希表。我的担忧:
至少有人能让我朝着正确的方向前进,我还没有在互联网上找到任何信息。谢谢
修改
我试过了:
//PROPERTIES of an object called "Information"
<?xml version="1.0" encoding="utf-8"?>
<Information xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CompileScript>false</CompileScript>
<SaveScript>false</SaveScript>
<ConvertPaths>false</ConvertPaths>
<UseUninstaller>true</UseUninstaller>
<UninstallSuccess>[NAME] was successfully removed from your computer. </UninstallSuccess>
<UninstallPrompt>Are you sure you want to completely remove [NAME] and all of its components?</UninstallPrompt>
<AllowChangeStartMenuFolderName>false</AllowChangeStartMenuFolderName>
//... (many others)
//Here starts KEYS & VALUES of my hashtable
<entry>
<fileName> My file name 1</fileName>
<instDir>My file location 1</instDir>
</entry>
<entry>
<fileName> My file name 2</fileName>
<instDir>My file location 2</instDir>
</entry>
//...and so on.
在最后一行引发了一个例外 - “XML文档中的错误(27,4)”。
我的原始XML(第一个是pseude代码):
XmlTextReader reader = new XmlTextReader("...Path...\\data.xml");
//the last element before the keys and values of a hashtable start
reader.ReadToDescendant("AllowChangeStartMenuFolderName");
XmlSerializer serializer = new XmlSerializer(typeof(Classes.Information));
//info is a new empty object which should be filled with values from the XML file
this.info = (Classes.Information)serializer.Deserialize(reader.ReadSubtree());
reader.Close();