Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Converting HTML tags to XML Well-Formed tags using AS3

New Here ,
Sep 10, 2009 Sep 10, 2009

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.

TOPICS
ActionScript
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 10, 2009 Sep 10, 2009

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 10, 2009 Sep 10, 2009

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 10, 2009 Sep 10, 2009

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.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 10, 2009 Sep 10, 2009

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]

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 10, 2009 Sep 10, 2009

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,

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Sep 10, 2009 Sep 10, 2009
LATEST

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines