473,815 Members | 1,704 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 2710
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.@strokewid th %>>
</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
1244
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 pk
2
1409
by: carlos | last post by:
How can we read / write numbers in a excel data sheet.
1
2089
by: amit260906 | last post by:
Can anybody tell me how to read Html file from Visual basic.
0
1700
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 button (at run time), they could see the result from the search engines. the code is in HTML and i don't know how to translate or convert into VB code. ...
3
1076
by: msnews.microsoft.com | last post by:
I have a constructor with parameters. __gc public class GpsUsbDevice : public GpsDevice { public: GpsUsbDevice(String* DeviceName) { }
1
1134
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 the file extension. Cheers, A4.
3
2918
by: HelloWorldHelloWorldHello | last post by:
How to send email to another person with using Microsoft Visual Basic 6.0.?
1
1356
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 help me. thnx in advance.
1
2875
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 it. and now i want to open that image in Ms-Word. please send me solution of it. I shall be Greatfull to u Thanx Amit *** Sent via Developersdex http://www.developersdex.com ***
0
9613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10673
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10430
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9227
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7689
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4360
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 we have to send another system
2
3889
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3032
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.