Subobjects?
[1/5] from: dan::rolander::marriott::com at: 28-Dec-2000 11:59
How does one access a subobject within an object?
[2/5] from: al:bri:xtra at: 29-Dec-2000 7:56
Dan wrote:
> How does one access a subobject within an object?
o: make object! [
so: make object! [
sm: 1
]
m: 2
]
>> o/m
== 2
>> o/so/sm
== 1
>> probe o/so
make object! [
sm: 1
]
I hope that helps!
Andrew Martin
ICQ: 26227169 http://members.nbci.com/AndrewMartin/
[3/5] from: dan:rolander:marriott at: 28-Dec-2000 15:17
Thanks Andrew. But I'm trying to figure out how to use Christian Ensel's
xml-processor.r (which I believe you had some comments on in November) and
I'm having some difficulty navigating the object tree. Using his
xml-test.xml I get this:
>> probe xml/the-document
make object! [
name: none
attrs: []
content: [
make object! [
name: "space:name"
attrs: []
content: ["^/ This is some text typed by " "Christian Ens
el" ".^/ "
make object! [
name: "che:money"
attrs: [
make object! [
name: "xmlns:che"
value: "http://www.foo.bar"
]
make object! [
name: "che:amount"
value: "0.02"
]
make object! [
name: "che:currency"
value: "USD"
]]
content: ["^/ My two cents?!?^/ "
make object! [
name: "element"
attrs: [
make object! [
name: "attribute"
value: "<1>"
]]
content: []
] "^/ "]
] "^/"]
]]
]
>>
I can probe xml/the-document/name, xml/the-document/attrs, and
xml/the-document/content, but nothing below that. What am I doing wrong?
Thanks,
Dan
[4/5] from: al:bri:xtra at: 29-Dec-2000 10:38
Dan wrote:
> I can probe xml/the-document/name, xml/the-document/attrs, and
xml/the-document/content, but nothing below that. What am I doing wrong?
Look very carefully here:
> content: [
> make object! [
> name: "space:name"
Note that 'content is a block! datatype. To access the object in there,
you'll need:
xml/the-document/content/1
to access the first object, then:
xml/the-document/content/1/name
to access the 'name word in that object.
I hope that helps!
Andrew Martin
ICQ: 26227169 http://members.nbci.com/AndrewMartin/
[5/5] from: dan:rolander:marriott at: 28-Dec-2000 23:47
Ok, I understand now. Thank you Andrew!
Dan