OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   How to embed xml in an html file, and parse the file using Sax?

[ Lists Home | Date Index | Thread Index ]
  • To: xml dev <xml-dev@lists.xml.org>, Anil Philip <goodnewsforyou@yahoo.com>
  • Subject: How to embed xml in an html file, and parse the file using Sax?
  • From: Anil Philip <goodnewsforyou@yahoo.com>
  • Date: Thu, 27 Jul 2006 11:19:48 -0700 (PDT)
  • Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=1n9K2hBvXVLpY6vYbI8qVEWp21KawIytXDXwUUZUCH1stibn+2U7Aewl7Cylw6dSex5CnCyLIzLP2l4+7agagZEE+B10tXRHrXN3bU9bf95IWqyQvVQ3iD8RQw9cgX2T8n9i0xrAxRupMjXRBqhhuPtK90QpNWb9NNxcGllVfTs= ;

I have an interesting design problem and wondered if
the gurus would have insight into it.
I need to have an html file that contains or embeds
data in xml and can be parsed by SAX.
  My xml file is like this:
<?xml version="1.0" encoding="ISO-8859-1"?>

  I want to put it inside or embed it in an html file.
The HTML file will be parsed by a SAX
parser, the html ignored, and the XML data extracted.
  When I posted this question long ago, some
(Megginson, Dane...) suggested I put the xml in
the <head> tags and use xhtml.
  So I implemented this:
Transitional//EN" "
  <xml version="1.0" encoding="ISO-8859-1">
<meta http-equiv="KEYWORDS" content=""/>
<meta http-equiv="DESCRIPTION" content=""/>

  Rest of the html.............
  In my content handler,
 public void characters(char[] text, int start, int
length) throws SAXException {
  if(skipContent) {
   skipContent = false;
 public void startElement(String namespaceURI, String
localName, String qualifiedName,
   Attributes atts) throws SAXException {
  ")) {
   skipContent = true;
  } else............
 public void endElement(String namespaceURI, String
localName, String qualifiedName)
   throws SAXException {
  ")) {
   skipContent = false;
  } else............
However I get parse errors
java.net.UnknownHostException: www.w3.org
 at java.net.PlainSocketImpl.connect(Unknown Source)

When I simply remove the <xml> tag and keep it as:
<?xml version="1.0" encoding="ISO-8859-1"?>

ie. inserting the xml file in between the <head>
then "namespaceURI"= "http://www.w3.org/1999/xhtml";
even while parsing the xml, so it fails
  Anyone knows how to do this?
Or is the answer that it cannot be done?
Any help appreciated plus you will have the
gratification of having contributed to a useful XML
tool that IMHO will benefit society.

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS