我有一个包含XML的字符串。我想从中创建一个XMLdocument。我正在使用这样的Load和LoadXMl方法:
Dim doc As XmlDocument
doc.LoadXml(applicationXml)
但他们正在重新调整:
Object reference not set to an instance of an object.
我的XML看起来像这样:
<gate.util.persistence.GateApplication>
<urlList class="gate.util.persistence.CollectionPersistence">
<localList>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/LingPipe/</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/Stemmer_Snowball/</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</localList>
<collectionType>java.util.ArrayList</collectionType>
</urlList>
<application class="gate.util.persistence.SerialAnalyserControllerPersistence">
<prList class="gate.util.persistence.CollectionPersistence">
<localList>
<gate.util.persistence.PRPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>setsToKeep</string>
<null />
</entry>
<entry>
<string>document</string>
<null/>
</entry>
<entry>
<string>annotationTypes</string>
<null/>
</entry>
<entry>
<string>corpus</string>
<null/>
</entry>
<entry>
<string>keepOriginalMarkupsAS</string>
<boolean>true</boolean>
</entry>
<entry>
<string>setsToRemove</string>
<null/>
</entry>
</localMap>
</runtimeParams>
<resourceType>gate.creole.annotdelete.AnnotationDeletePR</resourceType>
<resourceName>Document Reset PR</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.PRPersistence>
<gate.util.persistence.LanguageAnalyserPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>annotationSetName</string>
<null/>
</entry>
<entry>
<string>document</string>
<null/>
</entry>
</localMap>
</runtimeParams>
<resourceType>gate.creole.tokeniser.DefaultTokeniser</resourceType>
<resourceName>ANNIE English Tokeniser</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>tokeniserRulesURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/tokeniser/DefaultTokeniser.rules</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
<entry>
<string>transducerGrammarURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/tokeniser/postprocess.jape</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
<entry>
<string>encoding</string>
<string>UTF-8</string>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.LanguageAnalyserPersistence>
<gate.util.persistence.LanguageAnalyserPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>annotationSetName</string>
<null/>
</entry>
<entry>
<string>document</string>
<null/>
</entry>
</localMap>
</runtimeParams>
<resourceType>com.ontotext.gate.gazetteer.HashGazetteer</resourceType>
<resourceName>TCG Gazetteer</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>listsURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>http://halo.dyndns-web.com:96/tcg/GATE/Gazetteers/MasterListsDef.def</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
<entry>
<string>encoding</string>
<string>UTF-8</string>
</entry>
<entry>
<string>caseSensitive</string>
<boolean>false</boolean>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.LanguageAnalyserPersistence>
<gate.util.persistence.LanguageAnalyserPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>wholeWordsOnly</string>
<boolean>true</boolean>
</entry>
<entry>
<string>document</string>
<null/>
</entry>
<entry>
<string>longestMatchOnly</string>
<boolean>true</boolean>
</entry>
<entry>
<string>annotationSetName</string>
<null/>
</entry>
</localMap>
</runtimeParams>
<resourceType>gate.creole.gazetteer.DefaultGazetteer</resourceType>
<resourceName>ANNIE Gazetteer</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>gazetteerFeatureSeparator</string>
<null/>
</entry>
<entry>
<string>listsURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/gazetteer/lists.def</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
<entry>
<string>caseSensitive</string>
<boolean>true</boolean>
</entry>
<entry>
<string>encoding</string>
<string>UTF-8</string>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.LanguageAnalyserPersistence>
<gate.util.persistence.LanguageAnalyserPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>outputASName</string>
<null/>
</entry>
<entry>
<string>document</string>
<null/>
</entry>
<entry>
<string>inputASName</string>
<null/>
</entry>
</localMap>
</runtimeParams>
<resourceType>gate.creole.splitter.SentenceSplitter</resourceType>
<resourceName>ANNIE Sentence Splitter</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>encoding</string>
<string>UTF-8</string>
</entry>
<entry>
<string>gazetteerListsURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/sentenceSplitter/gazetteer/lists.def</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
<entry>
<string>transducerURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/sentenceSplitter/grammar/main.jape</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.LanguageAnalyserPersistence>
<gate.util.persistence.LanguageAnalyserPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>document</string>
<null/>
</entry>
<entry>
<string>corpus</string>
<null/>
</entry>
<entry>
<string>outputAnnotationType</string>
<string>Token</string>
</entry>
<entry>
<string>inputASName</string>
<null/>
</entry>
<entry>
<string>failOnMissingInputAnnotations</string>
<boolean>true</boolean>
</entry>
<entry>
<string>outputASName</string>
<null/>
</entry>
<entry>
<string>baseSentenceAnnotationType</string>
<string>Sentence</string>
</entry>
<entry>
<string>baseTokenAnnotationType</string>
<string>Token</string>
</entry>
</localMap>
</runtimeParams>
<resourceType>gate.creole.POSTagger</resourceType>
<resourceName>ANNIE POS Tagger</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>encoding</string>
<null/>
</entry>
<entry>
<string>rulesURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/heptag/ruleset</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
<entry>
<string>lexiconURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/heptag/lexicon</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.LanguageAnalyserPersistence>
<gate.util.persistence.LanguageAnalyserPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>outputASName</string>
<null/>
</entry>
<entry>
<string>document</string>
<null />
</entry>
<entry>
<string>inputASName</string>
<null/>
</entry>
</localMap>
</runtimeParams>
<resourceType>gate.creole.ANNIETransducer</resourceType>
<resourceName>ANNIE NE Transducer</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>encoding</string>
<string>UTF-8</string>
</entry>
<entry>
<string>annotationAccessors</string>
<null/>
</entry>
<entry>
<string>operators</string>
<null/>
</entry>
<entry>
<string>grammarURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/NE/main.jape</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.LanguageAnalyserPersistence>
<gate.util.persistence.LanguageAnalyserPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>annotationSetName</string>
<null/>
</entry>
<entry>
<string>document</string>
<null/>
</entry>
<entry>
<string>annotationTypes</string>
<gate.util.persistence.CollectionPersistence>
<localList>
<string>Organization</string>
<string>Person</string>
<string>Location</string>
<string>Date</string>
</localList>
<collectionType>java.util.ArrayList</collectionType>
</gate.util.persistence.CollectionPersistence>
</entry>
</localMap>
</runtimeParams>
<resourceType>gate.creole.orthomatcher.OrthoMatcher</resourceType>
<resourceName>ANNIE OrthoMatcher</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>definitionFileURL</string>
<gate.util.persistence.PersistenceManager-URLHolder>
<urlString>$gatehome$plugins/ANNIE/resources/othomatcher/listsNM.def</urlString>
</gate.util.persistence.PersistenceManager-URLHolder>
</entry>
<entry>
<string>minimumNicknameLikelihood</string>
<double>0.5</double>
</entry>
<entry>
<string>extLists</string>
<boolean>true</boolean>
</entry>
<entry>
<string>encoding</string>
<string>UTF-8</string>
</entry>
<entry>
<string>caseSensitive</string>
<boolean>false</boolean>
</entry>
<entry>
<string>highPrecisionOrgs</string>
<boolean>false</boolean>
</entry>
<entry>
<string>personType</string>
<string>Person</string>
</entry>
<entry>
<string>processUnknown</string>
<boolean>true</boolean>
</entry>
<entry>
<string>organizationType</string>
<string>Organization</string>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.LanguageAnalyserPersistence>
<gate.util.persistence.PRPersistence>
<runtimeParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>document</string>
<null/>
</entry>
<entry>
<string>annotationSetName</string>
<null/>
</entry>
<entry>
<string>annotationType</string>
<string>Token</string>
</entry>
<entry>
<string>annotationFeature</string>
<string>string</string>
</entry>
</localMap>
</runtimeParams>
<resourceType>stemmer.SnowballStemmer</resourceType>
<resourceName>Stemmer</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap>
<entry>
<string>language</string>
<string>english</string>
</entry>
</localMap>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</gate.util.persistence.PRPersistence>
</localList>
<collectionType>java.util.ArrayList</collectionType>
</prList>
<resourceType>gate.creole.SerialAnalyserController</resourceType>
<resourceName>ANNIE</resourceName>
<initParams class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</initParams>
<features class="gate.util.persistence.MapPersistence">
<mapType>gate.util.SimpleFeatureMapImpl</mapType>
<localMap/>
</features>
</application>
</gate.util.persistence.GateApplication>
请建议解决此问题。
答案 0 :(得分:4)
似乎您需要使用New
关键字,因为XmlDocument
是引用类型:
Dim doc as XmlDocument = new XmlDocument()
有关详细信息,请参阅http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.loadxml.aspx#Y0。