You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Barry Fritchman <ba...@yahoo.com> on 2000/12/19 22:28:30 UTC
URLInputSource -- what am I doing wrong?
When I run the simple program below to parse an XML
document specified by a URL, the result is "Error at
column 1 of line 1: Invalid document structure". The
XML document (also listed below) is well-formed, and
is successfully parsed if I access it with
LocalFileInputSource instead of URLInputSource. Is
there something I'm missing? I do have an
fgNetAccessor. I'm using the latest stable build of
1.3, running on NT 4.0 sp6, compiling with Visual C++
6.0. Thanks for any help or advice.
Here is the program:
#include <stdio.h>
#include <string.h>
#include <parsers/SAXParser.hpp>
#include <util/PlatformUtils.hpp>
#include <util/XMLURL.hpp>
#include <framework/URLInputSource.hpp>
#include <sax/SAXParseException.hpp>
#include <sax/HandlerBase.hpp>
int main()
{
try
{
XMLPlatformUtils::Initialize();
}
catch (const XMLException& toCatch)
{
printf("Error during initialization! Message:
%S\n",
toCatch.getMessage());
return 1;
}
if (!XMLPlatformUtils::fgNetAccessor)
{
printf("fgNetAccessor is NULL.\n");
return 1;
}
SAXParser parser;
HandlerBase handler;
parser.setDoValidation(0);
parser.setDocumentHandler(&handler);
parser.setErrorHandler(&handler);
XMLURL url("http://localhost:8080/orabook2.xml");
URLInputSource urlIS(url);
try
{
parser.parse(urlIS);
}
catch (SAXParseException ex)
{
printf("Error at column %d of line %d: %S\n",
ex.getColumnNumber(),
ex.getLineNumber(),
ex.getMessage());
return 1;
}
printf("Parse succeeded.\n");
return 0;
}
and here is the XML I'm trying to parse:
<?xml version = '1.0'?>
<page>
<ROWSET>
<ROW num="1">
<ISBN>1861003110</ISBN>
<TITLE>Professional XML</TITLE>
<CATEGORY>XML</CATEGORY>
<PRICE>34.99</PRICE>
</ROW>
</ROWSET>
</page>
__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/