B
Bappaditya
Hi,
I am relatively new to .net compact framework.I have created an
application where i have added a xml file and then created its
schema(from Create Schema in the toolbar). In a loading of a form, i
have written the following code to read the schema and the xml file:
Private exerciseDS As New DataSet
Private xmlFileName As String
Private xsdFileName As String
xmlFileName = "\program
files\SmartDeviceApplicationDemoXml\Exercise.xml"
xsdFileName = "\program
files\SmartDeviceApplicationDemoXml\Exercise.xsd"
Dim FsXML As New FileStream(xmlFileName, FileMode.Open)
Dim FsXSD As New FileStream(xsdFileName, FileMode.Open)
' Load the schema into the DataSet.
Dim xtrXSD As New XmlTextReader(FsXSD)
exerciseDS.ReadXmlSchema(xtrXSD)
xtrXSD.Close()
FsXSD.Close()
Dim xtrXML As New XmlTextReader(FsXML)
exerciseDS.ReadXml(xtrXML)
xtrXML.Close()
FsXML.Close()
Now this works fine enough.
But when i tried to create a xml file dynamically in the following
way:
Dim oXMLDOM As New XmlDocument
' Create Exercise root element
Dim oRoot As XmlElement = oXMLDOM.CreateElement("Exercise")
oXMLDOM.AppendChild(oRoot)
' Create new Exercise element
Dim oID As XmlElement = oXMLDOM.CreateElement("id")
oRoot.AppendChild(oID)
' Create new Exercise element
Dim oDate As XmlElement = oXMLDOM.CreateElement("Date")
oRoot.AppendChild(oDate)
' Create new Exercise element
Dim oTime As XmlElement = oXMLDOM.CreateElement("Time")
oRoot.AppendChild(oTime)
' Create new Exercise element
Dim oType As XmlElement = oXMLDOM.CreateElement("Type")
oRoot.AppendChild(oType)
'Create the xml processing instruction.
Dim oXMLPI As XmlProcessingInstruction =
oXMLDOM.CreateProcessingInstruction("xml", "version='1.0'
encoding='ISO-8859-1'")
'Append the processing instruction to the XML document.
oXMLDOM.InsertBefore(oXMLPI, oXMLDOM.ChildNodes(0))
' Save the document
oXMLDOM.Save("\program
files\SmartDeviceApplicationDemoXML\Exercise.xml")
I have successfully created the xml document. But i am to generate the
schema. I am also not getting any code anywhere. Can anyone help me
out?
Thanks
Bappaditya
I am relatively new to .net compact framework.I have created an
application where i have added a xml file and then created its
schema(from Create Schema in the toolbar). In a loading of a form, i
have written the following code to read the schema and the xml file:
Private exerciseDS As New DataSet
Private xmlFileName As String
Private xsdFileName As String
xmlFileName = "\program
files\SmartDeviceApplicationDemoXml\Exercise.xml"
xsdFileName = "\program
files\SmartDeviceApplicationDemoXml\Exercise.xsd"
Dim FsXML As New FileStream(xmlFileName, FileMode.Open)
Dim FsXSD As New FileStream(xsdFileName, FileMode.Open)
' Load the schema into the DataSet.
Dim xtrXSD As New XmlTextReader(FsXSD)
exerciseDS.ReadXmlSchema(xtrXSD)
xtrXSD.Close()
FsXSD.Close()
Dim xtrXML As New XmlTextReader(FsXML)
exerciseDS.ReadXml(xtrXML)
xtrXML.Close()
FsXML.Close()
Now this works fine enough.
But when i tried to create a xml file dynamically in the following
way:
Dim oXMLDOM As New XmlDocument
' Create Exercise root element
Dim oRoot As XmlElement = oXMLDOM.CreateElement("Exercise")
oXMLDOM.AppendChild(oRoot)
' Create new Exercise element
Dim oID As XmlElement = oXMLDOM.CreateElement("id")
oRoot.AppendChild(oID)
' Create new Exercise element
Dim oDate As XmlElement = oXMLDOM.CreateElement("Date")
oRoot.AppendChild(oDate)
' Create new Exercise element
Dim oTime As XmlElement = oXMLDOM.CreateElement("Time")
oRoot.AppendChild(oTime)
' Create new Exercise element
Dim oType As XmlElement = oXMLDOM.CreateElement("Type")
oRoot.AppendChild(oType)
'Create the xml processing instruction.
Dim oXMLPI As XmlProcessingInstruction =
oXMLDOM.CreateProcessingInstruction("xml", "version='1.0'
encoding='ISO-8859-1'")
'Append the processing instruction to the XML document.
oXMLDOM.InsertBefore(oXMLPI, oXMLDOM.ChildNodes(0))
' Save the document
oXMLDOM.Save("\program
files\SmartDeviceApplicationDemoXML\Exercise.xml")
I have successfully created the xml document. But i am to generate the
schema. I am also not getting any code anywhere. Can anyone help me
out?
Thanks
Bappaditya