Hi,
With the code below, I generate a XML file. It works well.
However, I need to put XML Schema specification in the head of XML document.
The generated XML doesn’t include that information.
Can you show me how to put the spec information in XML?
[code]
Dim xml As New XmlDocument
Dim root As XmlNode
root = xml.AppendChild(xml.CreateElement(“beans”))
Dim beanNode As XmlNode
Dim propertyNode As XmlNode
// Create 1st bean and its properties
beanNode = root.AppendChild(xml.CreateElement(“bean”))
beanNode.SetAttribute(“id”, “plan”)
beanNode.SetAttribute(“class”, “org.kt.d.conf.pn”)
propertyNode = beanNode.AppendChild(xml.CreateElement(“property”))
propertyNode.SetAttribute(“name”, “lname”)
propertyNode.SetAttribute(“value”, ST)
propertyNode = beanNode.AppendChild(xml.CreateElement(“property”))
propertyNode.SetAttribute(“name”, “rname”)
propertyNode.SetAttribute(“value”, TT)
propertyNode = beanNode.AppendChild(xml.CreateElement(“property”))
propertyNode.SetAttribute(“name”, “linfo”)
propertyNode.SetAttribute(“ref”, “linfo”)
propertyNode = beanNode.AppendChild(xml.CreateElement(“property”))
propertyNode.SetAttribute(“name”, “rinfo”)
propertyNode.SetAttribute(“ref”, “rinfo”)
propertyNode = beanNode.AppendChild(xml.CreateElement(“property”))
propertyNode.SetAttribute(“name”, “spath”)
propertyNode.SetAttribute(“value”, “./result”)
Dim prettyXML As String = xml.Transform(kPrettyPrintXSL)
'TextArea1.Text = xml.ToString
Textarea2.text = prettyXML[/code]
Generated XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xml="http://www.w3.org/XML/1998/namespace">
<bean id="plan" class="org.kt.d.conf.pn">
<property name="lname" value="TEST"/>
<property name="rname" value="TEST"/>
<property name="linfo" ref="linfo"/>
<property name="rinfo" ref="rinfo"/>
<property name="spath" value="./result"/>
</bean>
</beans>
Required XML
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="plan" class="org.kt.d.conf.pn">
<property name="lname" value="TEST" />
<property name="rname" value="TEST" />
<property name="linfo" ref="linfo" />
<property name="rinfo" ref="rinfo" />
<property name="spath" value="./result" />
</bean>
</beans>