Click here to Skip to main content
15,559,275 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 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 :

<sbml xmlns="" 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:

<MetaCyc xmlns:xsi="" xmlns:xsd="">

so how to deal with this problem when i using the xml Serialization in to read the sbml file.
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

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