On 12/5/06, Tony Pelton <[EMAIL PROTECTED]> wrote:
On 12/4/06, Lee <[EMAIL PROTECTED]> wrote:
> Michael Van Canneyt wrote:
> > On Sun, 3 Dec 2006, Lee wrote:
>
> I've only used a couple of XML DOM/Libraries and each seems to work
> differently than this although its probably just semantics.

fwiw,

i've done quite a bit of XML work over the years in Java for my day job.
any DOM implementation i've used in Java represents :

<foo>a value</foo>
as (2) nodes, <foo> being the parent of a "TEXT" node, and the text
node child being the node whose value is "a value".

Hello,

As the others have already mentioned:  when using DOM it is expected to have
a child node of type text . (this is probably true for SAX parsers, too)

I'd like to add just one thing:  it is not guaranteed to have only one child
node of type "text".  The "value" can be splitted across several "text" nodes.
So, in order to get the value you may need to access all the child nodes
of type "text" and concatenate their values.


a couple of other concepts that help to clarify why the DOM works this way :
<foo>a value<foo2>has another value</foo2></foo>.

"a value", the text node, and <foo2> are both child nodes of <foo>.
(forgive me, i always forget CDATA syntax ...)
<foo><!CDATA[a value]]/></foo>
... is structurally equivalent to ...
<foo>a value</foo>

this is very convenient from an API perspective, as the programmer
typically doesn't care about the "type" of the node holding the text
and it's behavior, you just want the text value, and again, it's
convenient that you don't have to worry about whether it is a "plain
text" node, or a "cdata" node.

if you _needed_ to know, you can interrogate the node for its type.

> For instance, with .net, I would access that value (123) with Node.InnerText.

my $0.02 ...

try to avoid learning how standards based mechanisms work by using MS
API's as your reference implementation.


--
Adrian Maier

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to