Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) How to use Diagram.saveToXml Method on clientside? (Read 5612 times)
wangzh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Apr 25th, 2009
How to use Diagram.saveToXml Method on clientside?
Apr 25th, 2009 at 3:32pm
Print Post  
I using the net diagram in JavaApplet mode. I want to get diagram XML by JavaScript on client-side.
The folowing code is working. But return empty. What am I doing wrong?

<script language="javascript">
function btnExport_click()
{
var doc = new ActiveXObject('Microsoft.XMLDOM');
document.getElementById('DiagramView1').getDiagram().saveToXml(doc);
alert(doc.xml);
}
</script>

why doc.xml is empty?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Diagram.saveToXml Method on clients
Reply #1 - Apr 26th, 2009 at 9:58am
Print Post  
Hi,

The saveToXml method expects a Java org.w3c.dom.Document object rather than an ActiveX Microsoft.XMLDOM one. You could use the Diagram.saveToString method to get the XML as a string, and then parse that string using any XML DOM API if you need access to individual elements.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
wangzh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Apr 25th, 2009
Re: How to use Diagram.saveToXml Method on clients
Reply #2 - Apr 26th, 2009 at 10:31am
Print Post  
hi Stoyan:

Thank you for your reply!
But I found that if the Chinese characters included, xml will appear garbled.
How I solve them?

Javascript Code is as follows:

var doc = new ActiveXObject('Msxml2.DOMDocument');
doc.loadXML(getApplet().getDiagram(false));
alert(doc.xml);

« Last Edit: Apr 27th, 2009 at 1:50am by wangzh »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Diagram.saveToXml Method on clients
Reply #3 - Apr 27th, 2009 at 9:01am
Print Post  
Hi,

This worked fine in our test:
Code
Select All
function test()
{
	var applet = <%= diagramView.AppletElement %>;
	var diagram = applet.getDiagram();

	// Base64 = 1;
	// Xml = 2;
	// CompressedXml = 3;
	var xml = diagram.saveToString(2, true);
	alert(xml);
}
 





I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
wangzh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Apr 25th, 2009
Re: How to use Diagram.saveToXml Method on clients
Reply #4 - Apr 28th, 2009 at 2:34am
Print Post  
hi Stoyan
    I do so in accordance with your method, but the Chinese characters are still garbled.
   My test Page has been sent to your mailbox(support@mindfusion.eu).
    Please help me solve this problem.
    thanks a lot!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Diagram.saveToXml Method on clients
Reply #5 - Apr 28th, 2009 at 8:13am
Print Post  
Hi,

I can see the Chinese characters ok in the text area:


Is the encoding attribute on the first line of the text area set to "UTF-16" after you press the save button? I think we set UTF16 as default encoding in one of the recent releases; if you get a different one, try that with version 3 of the control:
https://www.mindfusion.eu/NetDiagramTrial.zip

Stoyan
  
Back to top
 
IP Logged
 
wangzh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Apr 25th, 2009
Re: How to use Diagram.saveToXml Method on clients
Reply #6 - Apr 28th, 2009 at 9:38am
Print Post  
hi stoyan,

Please sent me a copy of your page right now.
my email address is "wzh_922@163.com".
Because my code is still wrong.

Very anxious!

thanks.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Diagram.saveToXml Method on clients
Reply #7 - Apr 28th, 2009 at 9:50am
Print Post  
I haven't changed anything in the pages you sent me. Are you using NetDiagram V3?
  
Back to top
 
IP Logged
 
wangzh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Apr 25th, 2009
Re: How to use Diagram.saveToXml Method on clients
Reply #8 - Apr 28th, 2009 at 11:05am
Print Post  
Yes, I have to upgrade Control to 3.0.
There will be other reasons for it?
I very need your help!
thanks a lot!
  
Back to top
 
IP Logged
 
wangzh
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 25
Joined: Apr 25th, 2009
Re: How to use Diagram.saveToXml Method on clients
Reply #9 - Apr 28th, 2009 at 11:10am
Print Post  
Running on my computer, click the savetostring button to generate the xml data is always utf-8 format, rather than utf-16 format.
I think it was caused by this reason,How can I do to utf-16 format to generate data?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to use Diagram.saveToXml Method on clients
Reply #10 - Apr 28th, 2009 at 11:11am
Print Post  
Do the characters appear correctly in the text area if you write something in Chinese there?
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint