473,498 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert svg to html using LINQ in visual basic?

1 New Member
I need help finishing a visual basic program that converts SVG to HTML using LINQ. The input in svg.xml should produce the output in target.html


Here is my svg.xml code:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" standalone="no"?>
  2. <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  3. "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
  4.  
  5. <svg width="100%" height="100%" version="1.1"
  6. xmlns="http://www.w3.org/2000/svg">
  7.  
  8.   <rect width="300" height="100" fill="rgb(120,90,255)" strokewidth="1" stroke="rgb(0,0,0)"
  9.   style="fill:rgb(120,90,255);stroke-width:1;
  10. stroke:rgb(0,0,0)"/>
  11.  
  12.   <rect x="120" y="20" width="250" height="250" fill="purple" strokewidth="5" stroke="purple"
  13. style="fill:green;stroke:purple;stroke-width:5;"/>
  14.  
  15.   <rect x="20" y="120" width="250" height="250" fill="blue" strokewidth="15" stroke="pink"
  16.   style="fill:blue;stroke:pink;stroke-width:15;"/>
  17.  
  18.   <rect x="200" y="200" width="250" fill="red" strokewidth="25" stroke="black"
  19.   height="100" style="fill:red;stroke:black;
  20. stroke-width:25;"/>
  21.  
  22. </svg>

Here is the desired output code ...
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <html>
  4.  
  5.   <body style="width: 100%; height: 100%">
  6.  
  7.     <div style="position: absolute; left: 20px ; top: 20px ; padding-bottom: 250px ; padding-right: 250px ; border-style: solid; border-width: 0px; background-color:blue;border-color:pink;border-width:5; fill-opacity:0.1;stroke-opacity:0.9"></div>
  8.  
  9.     <div style="position: absolute; left: 50px ; top: 100px ; padding-bottom: 5px ; padding-right: 10px ; border-style: solid; border-width: 0px; background-color:red;"></div>
  10.  
  11.     <div style="position: absolute; left: 200px ; top: 175px ; padding-bottom: 500px ; padding-right: 40px ; border-style: solid; border-width: 0px; background-color:purple; border-color:black; border-width: 10;"></div>
  12.  
  13.   </body>
  14.  
  15. </html> 

This is my visual basic code so far ... it outputs the html with the vector information as is. I want to alter it to change it to the desired output.
Expand|Select|Wrap|Line Numbers
  1. Imports <xmlns:svg="http://www.w3.org/2000/svg">
  2. ' *** LOOK OUT FOR THIS! ^^^^
  3.  
  4. Public Class Form1
  5.  
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         ' svg -> rect*
  8.         ' rect@x = 0, rect@y = 0, rect@width, rect@height
  9.         ' html -> body
  10.         ' body -> div*
  11.         ' <div style="position: absolute; left: ...
  12.         ' top: ... padding-bottom: ... padding-right: ...
  13.         ' 
  14.  
  15.  
  16.  
  17.     End Sub
  18.  
  19.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  20.  
  21.         Dim svg As XElement
  22.         svg = XElement.Load("../../test.svg.xml")
  23.  
  24.         Dim html = <html>
  25.                        <body style="width: 100%; height: 100%">
  26.  
  27.                            <%= From rectangle In svg.<svg:rect> Select <div style=<%= "position: absolute; left: " & rectangle.@x & _
  28.                                                                                       "px; top: " & rectangle.@y & _
  29.                                                                                       "px; padding-bottom: " & rectangle.@width & _
  30.                                                                                       "px; padding-right: " & rectangle.@height & _
  31.                                                                                       "px; border-style: solid; border-width: 0px; background-color: " & rectangle.@fill & _
  32.                                                                                       "; border-color: " & rectangle.@stroke & _
  33.                                                                                       "; border-width: " & _
  34.                                                                                       rectangle.@strokewidth %>>
  35.                                                                        </div> %>
  36.                        </body>
  37.                    </html>
  38.  
  39.         html.Save("../../result.html")
  40.  
  41.     End Sub
  42. End Class

If anybody can help me with this, it would be much appreciated!
Dec 5 '10 #1
1 2688
Benburrito
1 New Member
You almost have it, it's:
---------------------------------------------------
Dim html = <html>
<body style="width: 100%; height: 100%">

<%= From rect In svg...<svg> Select <div style=<%= "position: absolute; left: " & rect.@x & _
"px; top: " & rect.@y & _
"px; padding-bottom: " & rect.@width & _
"px; padding-right: " & rect.@height & _
"px; border-style: solid; border-width: 0px; background-color: " & rect.@fill & _
"; border-color: " & rect.@stroke & _
"; border-width: " & rect.@strokewidth %>>
</div> %>
</body>
</html>

html.Save("../../result.html")

-----------------------------------------------
The compliler will give you errors, not liking pink and so forth in the HTML, but it outputs it correctly.
Dec 8 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1230
by: pari kanaga | last post by:
Hi, Is there anyway to create a HTML file and Archieve by calling a dll in aspx page. I know its possible to render a html file by HtmlTextWriter. But I don't know How to use in Dll. thanks...
2
1395
by: carlos | last post by:
How can we read / write numbers in a excel data sheet.
1
2073
by: amit260906 | last post by:
Can anybody tell me how to read Html file from Visual basic.
0
1679
by: Faez | last post by:
i am using Visual Studio 2005 with Visual Basic language. i have a command button, labelled 'SEARCH' and i want to add the following code to the button; so that when people click on the search...
3
1062
by: msnews.microsoft.com | last post by:
I have a constructor with parameters. __gc public class GpsUsbDevice : public GpsDevice { public: GpsUsbDevice(String* DeviceName) { }
1
1115
by: a4poster | last post by:
Hi, I have constructed a form that when completed ouputs an HTML code. What I would like to know is how I can save this code that is wrote to a text file as an html file without physically changing...
3
2901
by: HelloWorldHelloWorldHello | last post by:
How to send email to another person with using Microsoft Visual Basic 6.0.?
1
1340
by: vai | last post by:
hi all i have created a html help file for my project which is developed using visual basic 6.0. i have used the shell.execute command as follows: Shell.Execute("Path"); it's not working.pls...
1
2844
by: amit saini | last post by:
Hi I have using back end sql server 2000, fornt end Visual Basic and For reporting using Ms-Word 2000. I have face a problem . In sql server i have using Image type data type and stored a image in...
0
7126
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7005
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7168
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6891
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7381
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4595
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3096
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3087
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1424
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.