GetLastChild [message #72960] |
Thu, 21 October 2010 14:29  |
Truong Le
Messages: 42 Registered: September 2010
|
Member |
|
|
Hi,
I am trying to get of the last child within a parent tag. However, I
always get the first child instead.
Any help is appreciated.
Thanks
|
|
|
Re: GetLastChild [message #73065 is a reply to message #72960] |
Fri, 22 October 2010 11:32  |
Karl[1]
Messages: 79 Registered: October 2005
|
Member |
|
|
On Oct 22, 9:42 am, Truong Le <truong...@gmail.com> wrote:
> On Oct 22, 11:04 am, Truong Le <truong...@gmail.com> wrote:
>
>
>
>> On Oct 21, 7:29 pm, David Fanning <n...@dfanning.com> wrote:
>
>>> Doug Edmundson writes:
>>>> The ALL_CHILDREN and N_CHILDREN keywords to WIDGET_INFO() should do the
>>>> trick.
>
>>> Better than my low-tech solution, probably. ;-)
>
>>> Cheers,
>
>>> David
>
>>> --
>>> David Fanning, Ph.D.
>>> Fanning Software Consulting, Inc.
>>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
>> Hi All,
>
>> Thank you for responses. I am pretty new to all these. However, I want
>> to get the last child using
>> the similar method that I get for the first child without using the
>> "item" keyword.
>> Below is how I go about obtaining the value of the first child.
>
>> doc = OBJ_NEW('IDLffXMLDOMDocument', FILENAME=filename)
>> elementValue = ((((doc->GetFirstChild())-> $
>> GetElementsByTagName(elementName))->item(0))-> $
>> GetFirstChild())->GetNodeValue()
>
>> Thanks,
>
>> Truong
>
> Okay, I think I found a way to resolve my problem, and here it is.
>
> doc = OBJ_NEW('IDLffXMLDOMDocument', FILENAME=filename)
> totalChild = (((doc->GetLastChild())-> $
> GetElementsByTagName(elementName)))-> $
> GetLength()
>
> elementValue = ((((doc->GetFirstChild())-> $
> GetElementsByTagName(elementName))->item(totalChild-1))-> $
> GetFirstChild())->GetNodeValue()
>
> Thank you all!
I bet I was one of the few who knew that you were talking about the
DOMDocument object instead of widgets.
GetLastChild() should work. Maybe if you post some sample XML that
you are using and the code that uses GetLastChild that does not work,
someone can figure out what is going on.
I note that you use doc->GetLastChild to get the count and then doc-
> GetFirstChild to get the parent of the element list. But I think
that both end up referring to the same object, so that should be ok.
You might try turning on the option to ignore ignorable whitespace.
Sometimes ignorable whitespace objects appear in the tree in
unexpected places and can interfere with accessing the elements.
|
|
|
Re: GetLastChild [message #73076 is a reply to message #72960] |
Fri, 22 October 2010 08:42  |
Truong Le
Messages: 42 Registered: September 2010
|
Member |
|
|
On Oct 22, 11:04 am, Truong Le <truong...@gmail.com> wrote:
> On Oct 21, 7:29 pm, David Fanning <n...@dfanning.com> wrote:
>
>> Doug Edmundson writes:
>>> The ALL_CHILDREN and N_CHILDREN keywords to WIDGET_INFO() should do the
>>> trick.
>
>> Better than my low-tech solution, probably. ;-)
>
>> Cheers,
>
>> David
>
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming:http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
>
> Hi All,
>
> Thank you for responses. I am pretty new to all these. However, I want
> to get the last child using
> the similar method that I get for the first child without using the
> "item" keyword.
> Below is how I go about obtaining the value of the first child.
>
> doc = OBJ_NEW('IDLffXMLDOMDocument', FILENAME=filename)
> elementValue = ((((doc->GetFirstChild())-> $
> GetElementsByTagName(elementName))->item(0))-> $
> GetFirstChild())->GetNodeValue()
>
> Thanks,
>
> Truong
Okay, I think I found a way to resolve my problem, and here it is.
doc = OBJ_NEW('IDLffXMLDOMDocument', FILENAME=filename)
totalChild = (((doc->GetLastChild())-> $
GetElementsByTagName(elementName)))-> $
GetLength()
elementValue = ((((doc->GetFirstChild())-> $
GetElementsByTagName(elementName))->item(totalChild-1))-> $
GetFirstChild())->GetNodeValue()
Thank you all!
|
|
|
Re: GetLastChild [message #73079 is a reply to message #72960] |
Fri, 22 October 2010 08:04  |
Truong Le
Messages: 42 Registered: September 2010
|
Member |
|
|
On Oct 21, 7:29 pm, David Fanning <n...@dfanning.com> wrote:
> Doug Edmundson writes:
>> The ALL_CHILDREN and N_CHILDREN keywords to WIDGET_INFO() should do the
>> trick.
>
> Better than my low-tech solution, probably. ;-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Hi All,
Thank you for responses. I am pretty new to all these. However, I want
to get the last child using
the similar method that I get for the first child without using the
"item" keyword.
Below is how I go about obtaining the value of the first child.
doc = OBJ_NEW('IDLffXMLDOMDocument', FILENAME=filename)
elementValue = ((((doc->GetFirstChild())-> $
GetElementsByTagName(elementName))->item(0))-> $
GetFirstChild())->GetNodeValue()
Thanks,
Truong
|
|
|
Re: GetLastChild [message #73107 is a reply to message #72960] |
Thu, 21 October 2010 16:29  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Doug Edmundson writes:
> The ALL_CHILDREN and N_CHILDREN keywords to WIDGET_INFO() should do the
> trick.
Better than my low-tech solution, probably. ;-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: GetLastChild [message #73108 is a reply to message #72960] |
Thu, 21 October 2010 16:21  |
Doug Edmundson
Messages: 58 Registered: November 2005
|
Member |
|
|
On 10/21/10 3:29 PM, Truong Le wrote:
> I am trying to get of the last child within a parent tag. However, I
> always get the first child instead.
The ALL_CHILDREN and N_CHILDREN keywords to WIDGET_INFO() should do the
trick.
Cheers,
Doug
|
|
|
Re: GetLastChild [message #73109 is a reply to message #72960] |
Thu, 21 October 2010 15:29  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Truong Le writes:
> I am trying to get of the last child within a parent tag. However, I
> always get the first child instead.
Get the first child of the parent, then look for
siblings until you get to the last, spoiled
child. That's the old that breaks the bank when
it comes to college expenses. :-(
sib = event.id
child = event.id
WHILE sib NE 0 DO BEGIN
sib = Widget_Info(child, /SIBLING)
IF sib NE 0 THEN child = sib
ENDWHILE
lastsib = child
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|