[Qt-interest] How to parse a paragraph twice with an XML stream parser?

Paul Miller paul at fxtech.com
Tue May 12 15:45:09 CEST 2009


Lingfa Yang wrote:
> Hi XML experts or XML application developers,
> 
> I am using QXmlStreamReader parsing document.xml. The file can be huge, 
> so I prefer this parser better than DOM.
> 
> The document.xml contains many paragraphs. With each paragraph I have to 
> parse it twice. I wish QXmlStreamReader can remember start element of 
> each p (Paragraph) tag. When finish the first time reading, reset to the 
> p tag again and read second time.  It seems QXmlStreamReader cannot do 
> that.

The stream reader simply can't do that - remember a "stream" could be a 
sequence of characters sent over a wire (like the Internet) and it's 
just cached anywhere.

What you should probably do is cache the contents of the element 
yourself. When you encounter one of these that you need to "read" twice, 
store the contents and related attributes in your own cache, then when 
you need to "read" it again, just read from your copy.

-- 
Paul Miller | paul at fxtech.com | www.fxtech.com | Got Tivo?




More information about the Qt-interest-old mailing list