SAX and children node

Patos <[email protected]>
Newsgroups gmane.text.xml.expat.general
Message-ID <[email protected]>
Hi,

I am trying to do a SAX parser on top of expat but I have some problem to
figure out if a node have children.
Im only able to resolve 2 of the 3 cases so I was wondering if someone could
help me.

Case 1 : <node att="value1"/> ok with that case.

Case 2: <node><child1/><child2/></node> thats ok.

Case 3 <node>textvalue</node>  <--- problem.

I dont know how to find out if its a node with children or a node with some
text value while im in the StartHandler.

There is what im doing :

void Reader::OnStartElement(const String &name, const char **atts)
{
    m_Depth++;
    Element *p = new Element(m_pCurrentReader, name);
    p->SetDepth(m_Depth);
    m_pCurrentReader->SetCurrentElement(p);
    for (int i = 0; atts[i]; i += 2)
    {
        p->AddAttribute(new Attribute(String(atts[i]), String(atts[i +
1])));
    }
    m_pCurrentReader->SetNodeComplete();
}

void Reader::OnEndElement(const String &name)
{
    Element *p = m_pCurrentReader->GetCurrentElement();
    p->SetHasChildren(m_Depth != p->GetDepth());
    m_Depth--;
    m_pCurrentReader->SetNodeComplete();
}

Maybe im not doing it the right way and I should try an other approach, plz
help me.

Patrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.