Yes Roger, I am aware of that. I inserted 2 comments into your code. One
addressing your problem and the other addressing a common problem
"NEWBIE"'s as you describe in you subject heading come into contact with
on a frequent basis.
If the modification I suggest does not fix your problem please feel free
to mail me personally.

Gareth


PS I insert the comment in the code below again.



Gareth Reakes, Lead Software Engineer  
DecisionSoft Ltd.            http://www.decisionsoft.com
Office: +44 (0) 1865 203192


On Sat, 24 Mar 2001, Williams Roger wrote:

> 
> I just want to know why the code I submitted with the first e-mail won't
> work. I have seen the DOMPrint sample. I don't want to Print anything, Just
> want to access the subnodes(all of them, not just the first one).
> 
> My question was , why does the getNextSibling not work in the following
> code.
> 
> xmldoc(I took out all unnec spaces) looks like:
> <root><properties><propone></propone><proptwo></proptwo></properties></root>
> 
> simplified code:              
>               DOMParser Parser;
>               Parser.parse(*memBufIS);                //option1:use membuf
>               //Parser.parse("c:/myxml.xml"); //option2:use file
>               Parser.setDoNamespaces(true);
>               DOM_Document DomDoc = Parser.getDocument();
>               DOM_NodeList NdLsPropTags =
> DomDoc.getElementsByTagName("properties"); 
>               int nPropTags;
>               if ((nPropTags = NdLsPropTags.getLength())!=1) {
>                       if (nPropTags==0) {
>                               printf("No properties tag");
>                       }       
>                       else {
>                               printf("More than one properties tag"); 
>                       }       
>                       return false;
>               }
>               printf("\nPropTags\t%d\n",nPropTags);
>               
>               DOMString dsNdNmProp,dsNdVlProp,dsNdNmNode,dsNdVlNode;
>               char
> *pszNdNmProp=NULL,*pszNdVlProp=NULL,*pszNdNmNode=NULL,*pszNdVlNode=NULL;
>               int nNdTpProp,nNdTpNode,i=0;    
>               
>               DOM_Node NdProp = NdLsPropTags.item(0); 
>               
>               nNdTpProp=NdProp.getNodeType();
>               dsNdNmProp=NdProp.getNodeName();
>               pszNdNmProp = dsNdNmProp.transcode();
>               dsNdVlProp = NdProp.getNodeValue();
>               if (pszNdVlProp==NULL)
>                       pszNdVlProp="NULL";
>       
> printf("\n\t%d\t%s\t%s\n",nNdTpProp,pszNdNmProp,pszNdVlProp);
>               
>               if (!NdProp.hasChildNodes())
>                       return false;
>               DOM_Node NdNode;
>               
>               NdNode = NdProp.getFirstChild();
>               if (NdNode.isNull()) 
>                       return true;
>               nNdTpNode = NdNode.getNodeType();
>               dsNdNmNode=NdNode.getNodeName();
>               pszNdNmNode = dsNdNmNode.transcode();
>               dsNdVlNode=NdNode.getNodeValue();
>               pszNdVlNode = dsNdVlNode.transcode();
>               if (pszNdVlNode==NULL)
>                       pszNdVlNode="NULL";
>       
> printf("\n%d\t%d\t%s\t\t<%s>\n",i,nNdTpNode,pszNdNmNode,pszNdVlNode);
>               
>               i++;
>               NdNode = NdProp.getNextSibling();
>               if (NdNode.isNull()) //turns out to be true
>                       return true; //ie no next sibling, cannot get
> proptwo

This will not work as NdProp is the element node Properties. It has no
siblings. The correct code should ask for the sibling of NdNode.

i.e.

NdNode = NdNode.getFirstSibling();


>               nNdTpNode = NdNode.getNodeType();
>               dsNdNmNode=NdNode.getNodeName();
>               pszNdNmNode = dsNdNmNode.transcode();
>               dsNdVlNode=NdNode.getNodeValue();
>               pszNdVlNode = dsNdVlNode.transcode();
>               if (pszNdVlNode==NULL)
>                       pszNdVlNode="NULL";
>       
> printf("\n%d\t%d\t%s\t\t<%s>\n",i,nNdTpNode,pszNdNmNode,pszNdVlNode);
> 
>               i++;
>               NdNode = NdProp.getNextSibling();
>               if (NdNode.isNull()) 
>                       return true;
>               nNdTpNode = NdNode.getNodeType();
>               dsNdNmNode=NdNode.getNodeName();
>               pszNdNmNode = dsNdNmNode.transcode();
>               dsNdVlNode=NdNode.getNodeValue();
>               pszNdVlNode = dsNdVlNode.transcode();
>               if (pszNdVlNode==NULL)
>                       pszNdVlNode="NULL";
>       
> printf("\n%d\t%d\t%s\t\t<%s>\n",i,nNdTpNode,pszNdNmNode,pszNdVlNode);
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to