Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, May 2007
Parsing XML with a DTD?


Message 1 in thread

hi to all,

can somebody give me a hint for parsing an XML (using a DTD
definition) file into an application?

I've took a look at the manual, but it is still criptical for me and I
don't understand how to do it. Basically I've to parse a XML file and
check that there are only valid elements with valid attributes. That
would be enough - of course, checking for data types would be optimal.

Best regards,
Daniel

--
 [ signature omitted ] 

Message 2 in thread

On 09.05.07 17:34:09, Daniel wrote:
> can somebody give me a hint for parsing an XML (using a DTD
> definition) file into an application?
> 
> I've took a look at the manual, but it is still criptical for me and I
> don't understand how to do it. Basically I've to parse a XML file and
> check that there are only valid elements with valid attributes. That
> would be enough - of course, checking for data types would be optimal.

I may be wrong, but I think the parsers in Qt are non-validating
parsers. Also with just a DTD data-type checking is kind of hard because
you don't have any data-types except element and attribute.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

Daniel wrote:

> can somebody give me a hint for parsing an XML (using a DTD
> definition) file into an application?

You might enjoy this little (console) program I put together.  I did not
include a .pro file, but since there are only 2 .cpp files and 1 .h file, I
figure you can handle that for yourself.  Compile it, feed in your
favorite .xml file(s), and it will show you everything the SAX parser does.

Regards,
Larry

Attachment:

Attachment: xmltest.zip
Description: Zip archive


Message 4 in thread

Larry Bristol wrote:

> Daniel wrote:
> 
>> can somebody give me a hint for parsing an XML (using a DTD
>> definition) file into an application?
> 
> You might enjoy this little (console) program I put together.  I did not
> include a .pro file, but since there are only 2 .cpp files and 1 .h file,
> I figure you can handle that for yourself.  Compile it, feed in your
> favorite .xml file(s), and it will show you everything the SAX parser
> does.

I just noticed a rather obvious bug in main()!  I rather doubt it will work
if you try to feed more than one file into it per execution.  <grin>

--
 [ signature omitted ]