DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Automate Migration Assessment With XML Linter
  • Hey Developers: Diagrams Don’t Need to Be So Complex
  • Validate XML Request Against XML Schema in Mule 4
  • Visualizing a Career Path

Trending

  • Top 7 Best Practices DevSecOps Team Must Implement in the CI/CD Process
  • What Is Kubernetes RBAC and Why Do You Need It?
  • [DZone Research] Join Us for Our 5th Annual Kubernetes Survey!
  • AI for Web Devs: Project Introduction and Setup
  1. DZone
  2. Data Engineering
  3. Data
  4. Export MS Visio Diagram to XML (VDX, VTX, VSX) Formats in C# & VB.NET

Export MS Visio Diagram to XML (VDX, VTX, VSX) Formats in C# & VB.NET

David Zondray user avatar by
David Zondray
·
Jan. 29, 14 · Code Snippet
Like (0)
Save
Tweet
Share
10.99K Views

Join the DZone community and get the full member experience.

Join For Free
This technical tip shows how .NET developers can export Microsoft Visio diagram to XML inside their own applications using Aspose.Diagram for .NET. Aspose.Diagram for .NET lets you export diagrams to a variety of formats: image formats, HTML, SVG, SWF and XML formats:
  • VDX defines an XML diagram.
  • VTX defines an XML template.
  • VSX defines an XML stencil.

The Diagram class' constructors read a diagram and the Save method is used to save, or export, a diagram in a different file format. The code snippets in this article show how to use the Save method to save a Visio file to VDX, VTX and VSX.

Exporting VSD to VDX

VDX is a schema-based XML file format that lets you save diagrams in a format that products other than Microsoft Visio can read. It's a useful format for transferring diagrams between software applications and retaining editable data.
To export a VSD diagram to VDX first create an instance of the Diagram class and call the Diagram class' Save method to write the Visio drawing file to VDX.

Exporting from VSD to VSX

VSX is an XML format for defining stencils, the basic objects from which a diagram is built up. When a Visio file is converted to VSX, only the stencils are exported.  To export a VSD diagram to VSX first you need to create an instance of the Diagram class and then call the Diagram class' Save method to write the Visio drawing file to VSX.

//The Sample code shows how to export VSD to VDX

//[C# Sample]
 
//Call the diagram constructor to load diagram from a VSD file
Diagram diagram = new Diagram("D:\\Drawing1.vsd");
this.Response.Clear();
this.Response.ClearHeaders();
this.Response.ContentType = "application/vnd.ms-visio";
this.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vdx");
this.Response.Flush();
System.IO.Stream vdxStream = this.Response.OutputStream;

//Save input VSD as VDX
diagram.Save(vdxStream, SaveFileFormat.VDX);
this.Response.End();

//[VB.NET Code Sample]

'Call the diagram constructor to load diagram from a VSD file
Dim diagram As New Diagram("D:\Drawing1.vsd")

Me.Response.Clear()
Me.Response.ClearHeaders()
Me.Response.ContentType = "application/vnd.ms-visio"
Me.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vdx")
Me.Response.Flush()
Dim vdxStream As System.IO.Stream = Me.Response.OutputStream

'Save inpupt VSD as VDX
diagram.Save(vdxStream, SaveFileFormat.VDX)
Me.Response.End()

//The Sample code shows how to export VSD to VSX format.

[C# Code Sample]

// Call the diagram constructor to load diagram from a VSD file
Diagram diagram = new Diagram("D:\\Drawing1.vsd");
this.Response.Clear();
this.Response.ClearHeaders();
this.Response.ContentType = "application/vnd.ms-visio";
this.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vsx");
this.Response.Flush();
System.IO.Stream vsxStream = this.Response.OutputStream;

//Save input VSD as VSX
diagram.Save(vsxStream, SaveFileFormat.VSX);
this.Response.End()

//[VB.NET Code Sample]

'Call the diagram constructor to load diagram from a VSD file
Dim diagram As New Diagram("D:\Drawing1.vsd")

Me.Response.Clear()
Me.Response.ClearHeaders()
Me.Response.ContentType = "application/vnd.ms-visio"
Me.Response.AppendHeader("Content-Disposition", "attachment; filename=Diagram.vsx")
Me.Response.Flush()
Dim vsxStream As System.IO.Stream = Me.Response.OutputStream

'Save input VSD as VSX
diagram.Save(vsxStream, SaveFileFormat.VSX)
Me.Response.End()
XML Diagram VB.NET

Opinions expressed by DZone contributors are their own.

Related

  • Automate Migration Assessment With XML Linter
  • Hey Developers: Diagrams Don’t Need to Be So Complex
  • Validate XML Request Against XML Schema in Mule 4
  • Visualizing a Career Path

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: