Converting HTML tags to XML Well-Formed tags using AS3
Copy link to clipboard
Copied
Hi all,
I have HTML file, I changed its extension to .XML.
I'd like to convert HTML tags to valid XML document using AS3.
Any ideas? Please participate.

Copy link to clipboard
Copied
If your HTML content is well formed and You don't have a <!DOCTYPE HTML > tag then your can directly use it as an XML.
And it will also be well formed.
Why you need it to be edited in AS3?

Copy link to clipboard
Copied
Please check the Following HTML file content.
If set its extension to .xml it will act like an XML file while if you set its extension to HTML it will act like HTML.
Notice that Every tag has an end tag attached to it and HTML is the root tag for all.
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Author" CONTENT="SwapnilVJ"/>
</HEAD>
<BODY>
<h1>This is my heading....</h1>
<img src="sample.gif" alt="This is the tooltip" />
</BODY>
</HTML>
Copy link to clipboard
Copied
I'm dealing with HTTML not XHTML.
So there are tags like <img> and <input>, they don't have a closed tag.
How can I check the file, if the tag dosen't have closed tag, it adds a closed one.
Also, for the attributes, if the attribute dosen't have quotes "", it will add guotes for it.
Thanks alot for helping me.

Copy link to clipboard
Copied
In my previous post I have added a singleton tag img with the closing of it.
Normally the tags which are singleton tags in HTML can beclosed by using /> at the ned of the tag
Like following:
<img src="abcd.gif" />
<input type="button" />
However, I agree with your point about Quotes. In HTML it is not mandatory to put quotes around a value.
But if it is possible then you can make it a habit to put quotes around all the HTML attribute values.
[This is also a standard practice]
Copy link to clipboard
Copied
I know that.
But I have a big mass of html files, I want to convert them into XML files automatically.
If you have an idea, please give it to me.
Thanks,

Copy link to clipboard
Copied
You can do this in AIR but not in flash.
If you do it in flash you wont be able to save the XML file without server script.
If you are really serious about doing it, then search and use Regex to match tag patterns and convert them into wellformed tags.
For this you will have to read the entire file as string and perform all string operations.
It is something like creating your own HTML/XML parser.
I don't see any direct methods available to do this.

