Parameter | Description |
---|---|
sNamespaceURI | Namespace-URI string (e.g. http://dataaccess.com/MyURI) |
sBaseName | Name of Element excluding the prefix |
Returns the object handle of the next sibling element node whose NamespaceURI and BaseName matches the passed values. Returns zero if no node is found.
Function NextElementNS string sNameSpaceURI string sBaseName Returns Handle
Call: | Get NextElementNS sNameSpaceURI sBaseName to HandleVariable |
NextElementNS is used to find the next sibling element with a passed NamespaceURI and BaseName. It returns the object Id of next node that matches or zero if no node is found. As with any XML object node, you must make sure you destroy the node when you are done with it.
This message will often be used with ChildElementNS to traverse a list of child objects. Assume you have the following xml document:
<CustomerList xmlns="http://www.dataaccess.com/Test/CustomerList"> <Customer> <Name>3A Software</Name> <Number>13</Number> <State>CA</State> </Customer> <Customer> <Name>Ace Manufacturers, Inc.</Name> <Number>4</Number> <State>IL</State> </Customer> <Customer> <Name>All Canada Brewing Company</Name> <Number>24</Number> <State>CA</State> </Customer> </CustomerList>
You could parse all customers as follows:
Move "http://www.dataaccess.com/Test/CustomerList" to sNS // the namespace Get DocumentElement of hoXML to hoRoot // this is CusomterList Get ChildElementNS of hoRoot sNS "Customer" to hoCust While (hoCust) Get ChildElementValueNS of hoCust sNS "Name" to sName Get ChildElementValueNS of hoCust sNS "Number" to sNumber Get ChildElementValueNS of hoCust sNS "State" to sState Send DoThisCustomer sName sNumber sState Get NextElementNS of hoCust sNS "Customer" to hoCust Loop
If you were sure that all of your child elements were the same, you could also use FirstChild and NextNode to do the same thing.
If your document does not have any namespaces or an element within the document does not have a namespace, its namespace is considered to be global and its NamespaceURI is represented as an empty string (""). In such a case you can and should use these namespace aware messages passing an empty string for the NameSpaceURI.
Note: | When parsing XML documents with namespaces you should always search by NamespaceURI and BaseName. You should not use the element's prefix and you should not attempt to ignore the NamespaceURI. |
ChildElementNS | ChildElementValueNS | IsElementNS | FirstChild | NextNode