` Printed Icetips Article

Icetips Article



XML: Using SV XML to navigate through XML
2005-01-11 -- Tony Bowes
 
Newsgroups: softvelocity.clarion.language


> >Try using the templates to import to a Queue instead. Just set up the
queue
> >to be the same file structure as your eventual file, then import into the
> >queue, then process the queue to check whether or not you want it in your
> >proper file. You can hack up the templates to read the data straight from
> >the DOM, but personally I think it's a waste of time.
>
> I would so much more like to have a real interface to this with a
> class so you could actually use it.  Methods with a Next() option so
> you could do this like a file access.  Oh, well:(
>

You can navigate your way through the document using the XMLnavigate wrapper
directly, although you will still need to hand-hold the exchange object to
actually do any work importing or exporting to the document. Here's a code
snippet that might help show a simple loop through the nodes of a DOM:

 cImpXMLNavigator &= cImpExch.getNavigator()
 cImpXMLNavigator.goToRoot()
 bImpXmlRet = cImpXMLNavigator.goToFirstChild()
 Loop
   If bImpXmlRet <> CPXMLErr:NoError 
     Break
   End
   If cImpXMLNavigator.getNodeName() = 'Orders'
     cImpXMLNavigator.setXMLExchangeNode()       
     ! Set the node back into the Exchange object
     bImpXmlRet = cImpExch.FromXML( cImpWrapperOD )   
     !And read in the set of OrderDetails for this order
     If bImpXmlRet <> CPXMLErr:NoError
       Message( 'An Error Occurred while Converting the XML Input. ' &|
                'The error returned was: ' & bImpXmlRet,|
                'Error Converting XML Output',|
                ICON:Hand, BUTTON:OK )
     End
   End
   bImpXmlRet = cImpXMLNavigator.goToNextSibling()
 End
 cImpExch.Close()


Tony Bowes



Printed May 12, 2024, 3:43 am
This article has been viewed/printed 35117 times.
Google search has resulted in 11 hits on this article since January 25, 2004.