Re: [bdbxml] XmlValue/XmlDocument problems
George Feinberg <[email protected]> Wed, 17 Aug 2005 15:59:07 -0400
| Newsgroups | gmane.comp.db.dbxml.general |
|---|---|
| Message-ID | <[email protected]> |
On Aug 17, 2005, at 3:29 PM, Jim Endicott wrote: > I think I have a fundamental disconnect on how to deal with the > results from a > query. > What I expected was that if I did a query like /foo I would get a > collection of > XmlValue objects in the XmlResults object, 1 for each <foo>...</ > foo> element > that was found. When I check the type of the value with (isNode == > true) that > would mean that I would want to access the value as a document > (asDocument()). The results you get back from XQuery are either nodes or typed values. An example of a typed value is the number 1.0 (decimal) or "joe" (a string). A node most likely represents either an attribute or an element. It's important to understand that a node is *not* the string representation of the XML, it is the node itself. You can get the string representation of the node (or typed value) using the asString() method of XmlValue. The asDocument() method exists for (live) nodes so that you can, if you so choose, navigate to the XmlDocument that contains that specific node. > I suspect that what is meant by ‘document’ in this context is the > XML file that > was added to the container as opposed to a well formed XML Document > and > therefore asDocument means that you want to access not the element > <foo> but the > xml file that it was found in?? Correct. > > In that case if I want to access the XmlValue as an xml fragment > when that is > what it is and as an atomic String, Boolean, etc when it isn’t, > what is the > right way to use the API? Per above, use XmlValue::asString() Regards, George ------------------------------------------ To remove yourself from this list, send an email to [email protected]