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 Eva Ko <ek...@hns.com> on 2001/10/03 23:22:51 UTC
getChildNodes seems to return invalid info.
Hi ,
I try to use the getChildNodes, but it return result and then core dump.
Am I doing anything incorrectly? I really need some help here. I am
using xerces C++ from the nightly build (9/14) on solaris.
I also attached my full code and data file. thanks for your help in
advance.
My xml looks like this:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE test SYSTEM "testing.dtd">
<test>
<CommandIndex value = "TBD"/>
<Argument>
<Record>
<ID value = "1"/>
<Clock value = "ENABLE"/>
</Record>
<Record>
<ID value = "1"/>
<Clock value = "ENABLE"/>
</Record>
</Argument>
</test>
I modifiied the DOMCount examples and added call to getChildNodes:
try
{
cout << " parsing buffer .. " << endl;
parser.parse("testing.xml");
DOM_Document doc = parser.getDocument();
DOM_Element root = doc.getDocumentElement();
DOM_NodeList demodClock =
root.getElementsByTagName(DOMString("Argument") );
DOM_NodeList childlist;
if ( demodClock.getLength() == 1 )
{
cout << " Name of doemclock child node: " <<
( ((DOM_Element&)(demodClock.item(0))
).getTagName()).transcode() << endl;
childlist = (demodClock.item(0)).getChildNodes();
}
else
{
cout << " Dup element" << endl;
return 1;
}
cout << " length: " << childlist.getLength() << endl;
for (int i = 0; i < childlist.getLength() ; i++)
{
cout << ( ((DOM_Element&)childlist.item(i)).getTagName()
).transcode() << endl;
}
***
its prints out this and core dumped
..../bin<9535> ./test
parsing buffer ..
Name of doemclock child node: Argument
length: 5
Segmentation Fault(coredump)
the lenght should be 2 , but it returns 5.
also, Name of doemclock child node should be "Record" .
thanks for your help
Eva