Click here to Skip to main content
15,512,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SBML is a kind of file format standard in the systems biology, and it is base on the xml file format. when i using the xml Serialization in vb.net to read the sbml file, then i get a problem, the xml namespace is not correct, so the program throw a exception to me:

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll

Additional information: There is an error in XML document (2, 2).


i think this error occur in the position of xml root node in a xml file :

XML
<sbml xmlns="http://www.sbml.org/sbml/level2" version="1" level="2">


line 2 , and the position at xmlns attribute.

i compare the sbml file with the normal xml file, easily found out that the namespace in a xml root node is diferrent:

XML
<MetaCyc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">


so how to deal with this problem when i using the xml Serialization in vb.net to read the sbml file.
Posted
Comments
Bernhard Hiller 10-Oct-13 3:35am    
How did you create the classes which correspond to the types described in SBML?
Mr. xieguigang 谢桂纲 10-Oct-13 7:14am    
just define a class follow the offical instruction pdf

Namespace MetaCyc.File.SBML

<system.xml.serialization.xmlroot("sbml")>
Public Class Xml
<system.xml.serialization.xmlattribute> Public Property version As Integer
<system.xml.serialization.xmlattribute> Public Property level As Integer

<system.xml.serialization.xmlelement> Public Model As ModelF

Public Shared Widening Operator CType(Path As String) As LANS.SystemsBiology.Assembly.MetaCyc.File.SBML.Xml
'从文件反序列化
Using fs As New System.IO.FileStream(Path, System.IO.FileMode.OpenOrCreate)
Return DirectCast(New System.Xml.Serialization.XmlSerializer(GetType(Xml)).Deserialize(fs), Xml)
End Using
End Operator
End Class
End Namespace

1 solution

Before you can deserialize the data, you must define the required classes. You'll need the xsd file (i.e. XML schema) and xsd.exe for that prupose. For more details, see my article "Bernie’s Trackviewer[^]", where I described that with GPX files (gps data encoded in XML).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900