on 10-20-2005 4:36 PM
Hi. I suggest you a little game.
Given an XML file defining a menu :
<?xml version="1.0" encoding="UTF-8"?>
<Application>
<Menus>
<action type="add">
<Menu Checked="0" Enabled="1" FatherUID="43520" Position="13" String="Miscellaneous Demo" Type="2" UniqueID="99999">
<Menus>
<action type="add">
<Menu Checked="0" Enabled="1" FatherUID="99999" Position="0" String="Custom Form" Type="1" UniqueID="menuCustomForm" />
</action>
</Menus>
</Menu>
</action>
</Menus>
</Application>
why this code create the menu
Private Sub AddMenuItems()
Dim oXmlDoc As New MSXML2.DOMDocument
Call oXmlDoc.load("MyMenu.xml")
Call m_app.LoadBatchActions(oXmlDoc.xml)
End Sub
and this other no?
Private Sub AddMenuItems()
Dim x As XmlDocument = New System.Xml.XmlDocument
x.Load("MyMenu.xml")
m_app.LoadBatchActions(x.InnerXml)
End Sub
Who give me the answer wins my many thanks.
Ciao. Nicola
As a stab in the dark, is it because the first one uses the xml() method where as the second uses the InnerXml() method?
What errors are you getting (if any)?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jon.
No error. Simply, the first one load the XML file in the B1 menu while the second one no.
The real difference is that in the first case the routine uses the MSXML ActiveX and works while in the second one the routine use the System.Xml.XmlDocument namespace in .NET framework and doesn't work.
Ciao.
Nicola
Ok. I found the problem.
The problem is the XML encoding. My file is an ANSI file (utf-8). Seems that MSXML interprets correctly an ANSI file while .NET use only Unicode (utf-16).
Infact, with my TextPad editor I created an Unicode file and I pasted the XML content setting the encode to utf-16 instead utf-8. Then I included the file in my .net project and, at last, it works.
Ciao.
Nicola
I only use the second way, and it works like a charm...
I'm using C#.Net though...
But, what the problem could be, a while ago, when I tried LoadBatchActions(myXmlDoc.InnerXML);</i> C# did throw me an error before compiling. Something about <i>myXmlDoc.InnerXML</i> was not allowed directly in <i>LoadBatchActions</i>. So try this:
<b>Code (C#)</b>
private void AddMenuItems()
{
/* New XML document */
XmlDocument x = new System.Xml.XmlDocument();
/* Load the xmfile and put it's content in a string */
x.Load("MyMenu.xml");
string sXML = x.InnerXml;
/* Load the xml into the SBO application */
SBO_Application.LoadBatchActions(sXML);
}
Probatly that wil work.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.