Jump to content

HTML to xml conversion

- - - - -

  • Please log in to reply
3 replies to this topic

#1
murugavelb

murugavelb

    Newbie

  • Members
  • PipPip
  • 11 posts
how to perform the html to xml conversion.....

Actually i used the grab the data from a website by using FILE_GET_CONTENTS and save it in my Hard disk as *.txt file by using FILE_PUT_CONTENTS.
i just want to convert that data into .xml file.To extract the particular data from that content.

#2
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
Why not just treat it as an XML file? Though you probably would need to do a bit of cleanup (ie terminating unended tags, enclosing non-quoted values in quotes, etc.), to make the HTML code into valid XML code.

#3
murugavelb

murugavelb

    Newbie

  • Members
  • PipPip
  • 11 posts
Thanks for rly dude....
i simply create a new xml file and named it as *.xml and using FILE_PUT_CONTENTS function i stored that retrieved data into *.xml file. but it doesn't work properly.....

#4
RhetoricalRuvim

RhetoricalRuvim

    JavaScript Programmer

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,254 posts
  • Location:C:\Countries\US
One thing I could say is make sure that the XML text is valid. Some requirements that I can think of, for an XML file to be valid, are:
  • There should be a root tag.
  • Tags should be properly nested.

    That is, if P is the parent element and DIV is the child, then you must first end the child element, before you can end the parent element. This is WRONG: "<p><div>hello</p></div>" This is RIGHT: "<p><div>hello</div></p>"

  • Each opening tag must have a corresponding closing tag.

    This is WRONG: "<p> hello"
    This is RIGHT: "<p> hello </p>"
    (You must close every tag you open.)

  • Each value, of a tag's attribute, must be quoted.

    This is WRONG: "<font size=5>...</font>"
    This is RIGHT: "<font size="5">...</font>"


Again, these are just some I can think of at the moment. There's more at XML Syntax .




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users