Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic getting canvas content in XML schema (Read 4051 times)
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
getting canvas content in XML schema
Apr 11th, 2017 at 5:57am
Print Post  
lets I can save XML file like following, how to get that XML schema in code level

Code
Select All
<Diagram Version="17">
  <Nodes />
  <Links/>
  <Properties>
    <ItemCounter>1</ItemCounter>
    <LinkHeadShape Id="Arrow" />
    <Images Count="0" />
    <Stencils Count="0" />
  </Resources>
  <Layers ActiveLayer="-1" />
</Diagram> 




I'm trying to get canvas content in to string variable like following

Approach 1

Code
Select All
 var canvasContent = diagram.Content; 



Approach 2

Code
Select All
 var canvasContent = diagram.SaveToString(); 



but from each of above I cant get exact XML schema like its saving to XML file
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: getting canvas content in XML schema
Reply #1 - Apr 11th, 2017 at 7:39am
Print Post  
Try with var canvasContent = diagram.SaveToString(SaveToStringFormat.Xml);
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: getting canvas content in XML schema
Reply #2 - Apr 11th, 2017 at 8:09am
Print Post  
once I put that getting following compile time error there
`There is no argument given that corresponds to the required formal parameter 'clearDirty' of 'Diagram.SaveToString(SaveToStringFormat, bool)'      `
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: getting canvas content in XML schema
Reply #3 - Apr 11th, 2017 at 8:23am
Print Post  
add a true or false argument depending on whether you consider this a save operation (the Dirty flag specifies whether diagram has been modified since last save).
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: getting canvas content in XML schema
Reply #4 - Apr 11th, 2017 at 8:42am
Print Post  
Now I can see its coming

but how to remove following line or get that xml file without following line

Code
Select All
<?xml version="1.0" encoding="utf-16"?> 


  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: getting canvas content in XML schema
Reply #5 - Apr 11th, 2017 at 8:46am
Print Post  
Try calling xmlString.Subsrtring(41), if I've counted the characters correctly.
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: getting canvas content in XML schema
Reply #6 - Apr 11th, 2017 at 8:59am
Print Post  
I tried following, but not working

string canvasContent = diagram.SaveToString(SaveToStringFormat.Xml.Substring(41), false);

string canvasContent = diagram.SaveToString(SaveToStringFormat.xmlString.Subsrtring(41), false);

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: getting canvas content in XML schema
Reply #7 - Apr 11th, 2017 at 9:13am
Print Post  
You want to call this on the string returned by SaveToString, so canvasContent = canvasContent.Substring(41);
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint