Thread: RE: [xmljs-users] Cannot write back to root document object...
Brought to you by:
djoham,
witchhunter
From: Eljon G. <eg...@re...> - 2004-07-29 18:20:37
|
Sure, Here is an example of the code: function removeNode(tElement,tOrder){ if(pageRoot.getElementsByTagName(tElement).item(tOrder-1) !=3D null) { =20 tNode =3D pageRoot.getElementsByTagName(tElement).item(tOrder-1); // Get first element by node name (i.e. section, fieldgroup, fields)=20 =09 tNode.getElementsByTagName('active').item(0).setNodeValue("No"); // Set active element to "No" try { =09 alert(tNode.getElementsByTagName('active').item(0).getNodeValue()); // Displays "No" =09 alert(tNode.getElementsByTagName('active').item(0).getXML()); // Displays <active>Yes</active> =09 } catch(e) { // Catch any exception if(e.code =3D=3D DOMException.NO_MODIFICATION_ALLOWED_ERR) { // display the error message=20 alert("XML Exception Error: Code not remove " + tElement + "."); } else { alert("Unknown exception"); alert(e.code);=20 } } } else { alert("Null object"); }=09 } Thanks for your assistance. Eljon -----Original Message----- From: xml...@li... [mailto:xml...@li...] On Behalf Of David Joham Sent: Thursday, July 29, 2004 11:33 AM To: Eljon Greene; xml...@li... Subject: Re: [xmljs-users] Cannot write back to root document object... Hi Eljon! Can you whip up a quick recreation of the problem you're seeing please? I'll take a look and see what's up... David --- Eljon Greene <eg...@re...> wrote: > Hey guys, >=20 > I am new to XML for <script>. Everything is coming along pretty good=20 > except for one thing...That is trying to write back to the parent=20 > document node so that I can save this information on the server. I=20 > can use "DOMNode.setNodeValue()" and then use "DOMNode.getNodeValue()" > and it works. However when I try "DOMNode.getXML()" the old value=20 > still exists...I am trying to use global variables in my method=20 > instead of the local variables. What am I doing wrong and how do I=20 > write back to the "DOMDocument"? Thanks... >=20 >=20 > Eljon Greene > Web Software Engineer > 877.394.5644 \\ main > 904.567.2127 \\ direct > eg...@re... > www.recruitmax.com >=20 ------------------------------------------------------- This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com _______________________________________________ xmljs-users mailing list xml...@li... https://lists.sourceforge.net/lists/listinfo/xmljs-users |
From: David J. <dj...@ya...> - 2004-07-29 18:34:37
|
I won't be able to look at this until tonight at the earliest, but I'll try to get to it as soon as possible. Can I ask a favor? Can you expand on this recreation a bit to include your source XML and everything you need to recreate this - including the creation of the objects? That will make it much easier for me to debug since I won't have to guess what your variables are or how the function is supposed to interact with the objects. It's actually easier for me when I have a slightly larger test case than the bare minimum. Sorry I wasn't clear about that originally... If you don't have time, that's OK. I'll do my best. One more favor :) Can you send the new|current recreation as a zipped up attachment to djoham[at]yahoo[dot]com please? Yahoo mail mutilates code (and text attachments) to the point of almost uselessness. It would be a big help if I was able to start with something that resembed JavaScript code rather than Perl :) Best regards, David --- Eljon Greene <eg...@re...> wrote: > Sure, > > Here is an example of the code: > > function removeNode(tElement,tOrder){ > if(pageRoot.getElementsByTagName(tElement).item(tOrder-1) != > null) { > tNode = > pageRoot.getElementsByTagName(tElement).item(tOrder-1); // Get first > element by node name (i.e. section, fieldgroup, fields) > > tNode.getElementsByTagName('active').item(0).setNodeValue("No"); // Set > active element to "No" > try { > > alert(tNode.getElementsByTagName('active').item(0).getNodeValue()); // > Displays "No" > > alert(tNode.getElementsByTagName('active').item(0).getXML()); // > Displays <active>Yes</active> > > } catch(e) { // Catch any exception > if(e.code == > DOMException.NO_MODIFICATION_ALLOWED_ERR) { > // display the error message > alert("XML Exception Error: Code > not remove " + tElement + "."); > } else { > alert("Unknown exception"); > alert(e.code); > } > } > } else { > alert("Null object"); > } > } > > Thanks for your assistance. > > Eljon > > -----Original Message----- > From: xml...@li... > [mailto:xml...@li...] On Behalf Of David > Joham > Sent: Thursday, July 29, 2004 11:33 AM > To: Eljon Greene; xml...@li... > Subject: Re: [xmljs-users] Cannot write back to root document object... > > > > Hi Eljon! > > Can you whip up a quick recreation of the problem you're seeing please? > I'll take a look and see what's up... > > > David > > --- Eljon Greene <eg...@re...> wrote: > > > Hey guys, > > > > I am new to XML for <script>. Everything is coming along pretty good > > except for one thing...That is trying to write back to the parent > > document node so that I can save this information on the server. I > > can use "DOMNode.setNodeValue()" and then use "DOMNode.getNodeValue()" > > > and it works. However when I try "DOMNode.getXML()" the old value > > still exists...I am trying to use global variables in my method > > instead of the local variables. What am I doing wrong and how do I > > write back to the "DOMDocument"? Thanks... > > > > > > Eljon Greene > > Web Software Engineer > > 877.394.5644 \\ main > > 904.567.2127 \\ direct > > eg...@re... > > www.recruitmax.com > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > |
From: David J. <dj...@ya...> - 2004-07-30 17:42:22
|
Hi Eljon! I think the problem is that you're setting the node Value on the element, rather than the text node child of the element. You have pageRoot.getElementsByTagName(tElement).item(tOrder-1).getElementsByTagName('active').item(0).setNodeValue("No"); which will set the node value of the <active> element, but not the text node under it. I think what you want to do is this: pageRoot.getElementsByTagName(tElement).item(tOrder-1).getElementsByTagName('active').item(0).getFirstChild().setNodeValue("No"); Note the addition of the getFirstChild() call. That will return the text node that you're actually interested in. Actually, on text nodes you're supposed to use setData rather than setNodeValue, but if you look at the code, all xmljs does in a setData is call setNodeValue so it doesn't really matter from a technical perspective... The code above will set the node data/value (the visible text so to speak) of the text node enclosed by the <active> node. When reading this value, you'll want to also make sure you're reading from the text node to make sure you're actually getting the node value of the text object. You can sometimes get away with not doing this, but it's not advised. Please go ahead and give that a shot and let us know how it turns out.... David --- Eljon Greene <eg...@re...> wrote: > Sure, > > Here is an example of the code: > > function removeNode(tElement,tOrder){ > if(pageRoot.getElementsByTagName(tElement).item(tOrder-1) != > null) { > tNode = > pageRoot.getElementsByTagName(tElement).item(tOrder-1); // Get first > element by node name (i.e. section, fieldgroup, fields) > > tNode.getElementsByTagName('active').item(0).setNodeValue("No"); // Set > active element to "No" > try { > > alert(tNode.getElementsByTagName('active').item(0).getNodeValue()); // > Displays "No" > > alert(tNode.getElementsByTagName('active').item(0).getXML()); // > Displays <active>Yes</active> > > } catch(e) { // Catch any exception > if(e.code == > DOMException.NO_MODIFICATION_ALLOWED_ERR) { > // display the error message > alert("XML Exception Error: Code > not remove " + tElement + "."); > } else { > alert("Unknown exception"); > alert(e.code); > } > } > } else { > alert("Null object"); > } > } > > Thanks for your assistance. > > Eljon > > -----Original Message----- > From: xml...@li... > [mailto:xml...@li...] On Behalf Of David > Joham > Sent: Thursday, July 29, 2004 11:33 AM > To: Eljon Greene; xml...@li... > Subject: Re: [xmljs-users] Cannot write back to root document object... > > > > Hi Eljon! > > Can you whip up a quick recreation of the problem you're seeing please? > I'll take a look and see what's up... > > > David > > --- Eljon Greene <eg...@re...> wrote: > > > Hey guys, > > > > I am new to XML for <script>. Everything is coming along pretty good > > except for one thing...That is trying to write back to the parent > > document node so that I can save this information on the server. I > > can use "DOMNode.setNodeValue()" and then use "DOMNode.getNodeValue()" > > > and it works. However when I try "DOMNode.getXML()" the old value > > still exists...I am trying to use global variables in my method > > instead of the local variables. What am I doing wrong and how do I > > write back to the "DOMDocument"? Thanks... > > > > > > Eljon Greene > > Web Software Engineer > > 877.394.5644 \\ main > > 904.567.2127 \\ direct > > eg...@re... > > www.recruitmax.com > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > |
From: Eljon G. <eg...@re...> - 2004-08-02 12:34:06
|
David, I just want to say thanks for your assistance...Everything is working fine = now.... Eljon Greene Web Software Engineer 877.394.5644 \\ main 904.567.2127 \\ direct eg...@re... www.recruitmax.com From: David Joham Sent: Fri 7/30/2004 1:42 PM To: Eljon Greene; xml...@li... Subject: RE: [xmljs-users] Cannot write back to root document object... Hi Eljon! I think the problem is that you're setting the node Value on the element, r= ather than the text node child of the element. You have pageRoot.getElementsByTagName(tElement).item(tOrder-1).getElementsByTagName= ('active').item(0).setNodeValue("No"); which will set the node value of the <active> element, but not the text nod= e under it. I think what you want to do is this: pageRoot.getElementsByTagName(tElement).item(tOrder-1).getElementsByTagName= ('active').item(0).getFirstChild().setNodeValue("No"); Note the addition of the getFirstChild() call. That will return the text no= de that you're actually interested in. Actually, on text nodes you're supposed to use setData rather than setNodeV= alue, but if you look at the code, all xmljs does in a setData is call setNodeValue so it doesn't= really matter from a technical perspective... The code above will set the node data/value (the visible text so to speak) = of the text node enclosed by the <active> node. When reading this value, you'll want to also= make sure you're reading from the text node to make sure you're actually getting the node va= lue of the text object. You can sometimes get away with not doing this, but it's not advised. Please go ahead and give that a shot and let us know how it turns out.... David --- Eljon Greene <eg...@re...> wrote: > Sure, >=20 > Here is an example of the code: >=20 > function removeNode(tElement,tOrder){ > if(pageRoot.getElementsByTagName(tElement).item(tOrder-1) !=3D > null) { =20 > tNode =3D > pageRoot.getElementsByTagName(tElement).item(tOrder-1); // Get first > element by node name (i.e. section, fieldgroup, fields)=20 > =09 > tNode.getElementsByTagName('active').item(0).setNodeValue("No"); // Set > active element to "No" > try { > =09 > alert(tNode.getElementsByTagName('active').item(0).getNodeValue()); // > Displays "No" > =09 > alert(tNode.getElementsByTagName('active').item(0).getXML()); // > Displays <active>Yes</active> > =09 > } catch(e) { // Catch any exception > if(e.code =3D=3D > DOMException.NO_MODIFICATION_ALLOWED_ERR) { > // display the error message=20 > alert("XML Exception Error: Code > not remove " + tElement + "."); > } else { > alert("Unknown exception"); > alert(e.code);=20 > } > } > } else { > alert("Null object"); > }=09 > } >=20 > Thanks for your assistance. >=20 > Eljon >=20 > -----Original Message----- > From: xml...@li... > [mailto:xml...@li...] On Behalf Of David > Joham > Sent: Thursday, July 29, 2004 11:33 AM > To: Eljon Greene; xml...@li... > Subject: Re: [xmljs-users] Cannot write back to root document object... >=20 >=20 >=20 > Hi Eljon! >=20 > Can you whip up a quick recreation of the problem you're seeing please? > I'll take a look and see what's up... >=20 >=20 > David >=20 > --- Eljon Greene <eg...@re...> wrote: >=20 > > Hey guys, > >=20 > > I am new to XML for <script>. Everything is coming along pretty good=20 > > except for one thing...That is trying to write back to the parent=20 > > document node so that I can save this information on the server. I=20 > > can use "DOMNode.setNodeValue()" and then use "DOMNode.getNodeValue()" >=20 > > and it works. However when I try "DOMNode.getXML()" the old value=20 > > still exists...I am trying to use global variables in my method=20 > > instead of the local variables. What am I doing wrong and how do I=20 > > write back to the "DOMDocument"? Thanks... > >=20 > >=20 > > Eljon Greene > > Web Software Engineer > > 877.394.5644 \\ main > > 904.567.2127 \\ direct > > eg...@re... > > www.recruitmax.com > >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users >=20 ------------------------------------------------------- This SF.Net email is sponsored by OSTG. Have you noticed the changes on Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, one more big change to announce. We are now OSTG- Open Source Technology Group. Come see the changes on the new OSTG site. www.ostg.com _______________________________________________ xmljs-users mailing list xml...@li... https://lists.sourceforge.net/lists/listinfo/xmljs-users |
From: David J. <dj...@ya...> - 2004-08-03 15:34:34
|
Yea! Good luck with the rest of your project! David --- Eljon Greene <eg...@re...> wrote: > David, > > I just want to say thanks for your assistance...Everything is working fine now.... > > Eljon Greene > Web Software Engineer > 877.394.5644 \\ main > 904.567.2127 \\ direct > eg...@re... > www.recruitmax.com > > > > > From: David Joham > Sent: Fri 7/30/2004 1:42 PM > To: Eljon Greene; xml...@li... > Subject: RE: [xmljs-users] Cannot write back to root document object... > > > Hi Eljon! > > I think the problem is that you're setting the node Value on the element, rather than the text > node child of the element. You have > > pageRoot.getElementsByTagName(tElement).item(tOrder-1).getElementsByTagName('active').item(0).setNodeValue("No"); > > which will set the node value of the <active> element, but not the text node under it. > > > I think what you want to do is this: > pageRoot.getElementsByTagName(tElement).item(tOrder-1).getElementsByTagName('active').item(0).getFirstChild().setNodeValue("No"); > > Note the addition of the getFirstChild() call. That will return the text node that you're > actually > interested in. > > Actually, on text nodes you're supposed to use setData rather than setNodeValue, but if you look > at the code, all xmljs does in a setData is call setNodeValue so it doesn't really matter from a > technical perspective... > > The code above will set the node data/value (the visible text so to speak) of the text node > enclosed by the <active> node. When reading this value, you'll want to also make sure you're > reading from the text node to make sure you're actually getting the node value of the text > object. > You can sometimes get away with not doing this, but it's not advised. > > Please go ahead and give that a shot and let us know how it turns out.... > > > David > > > --- Eljon Greene <eg...@re...> wrote: > > > Sure, > > > > Here is an example of the code: > > > > function removeNode(tElement,tOrder){ > > if(pageRoot.getElementsByTagName(tElement).item(tOrder-1) != > > null) { > > tNode = > > pageRoot.getElementsByTagName(tElement).item(tOrder-1); // Get first > > element by node name (i.e. section, fieldgroup, fields) > > > > tNode.getElementsByTagName('active').item(0).setNodeValue("No"); // Set > > active element to "No" > > try { > > > > alert(tNode.getElementsByTagName('active').item(0).getNodeValue()); // > > Displays "No" > > > > alert(tNode.getElementsByTagName('active').item(0).getXML()); // > > Displays <active>Yes</active> > > > > } catch(e) { // Catch any exception > > if(e.code == > > DOMException.NO_MODIFICATION_ALLOWED_ERR) { > > // display the error message > > alert("XML Exception Error: Code > > not remove " + tElement + "."); > > } else { > > alert("Unknown exception"); > > alert(e.code); > > } > > } > > } else { > > alert("Null object"); > > } > > } > > > > Thanks for your assistance. > > > > Eljon > > > > -----Original Message----- > > From: xml...@li... > > [mailto:xml...@li...] On Behalf Of David > > Joham > > Sent: Thursday, July 29, 2004 11:33 AM > > To: Eljon Greene; xml...@li... > > Subject: Re: [xmljs-users] Cannot write back to root document object... > > > > > > > > Hi Eljon! > > > > Can you whip up a quick recreation of the problem you're seeing please? > > I'll take a look and see what's up... > > > > > > David > > > > --- Eljon Greene <eg...@re...> wrote: > > > > > Hey guys, > > > > > > I am new to XML for <script>. Everything is coming along pretty good > > > except for one thing...That is trying to write back to the parent > > > document node so that I can save this information on the server. I > > > can use "DOMNode.setNodeValue()" and then use "DOMNode.getNodeValue()" > > > > > and it works. However when I try "DOMNode.getXML()" the old value > > > still exists...I am trying to use global variables in my method > > > instead of the local variables. What am I doing wrong and how do I > > > write back to the "DOMDocument"? Thanks... > > > > > > > > > Eljon Greene > > > Web Software Engineer > > > 877.394.5644 \\ main > > > 904.567.2127 \\ direct > > > eg...@re... > > > www.recruitmax.com > > > > > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > > one more big change to announce. We are now OSTG- Open Source Technology > > Group. Come see the changes on the new OSTG site. www.ostg.com > > _______________________________________________ > > xmljs-users mailing list > > xml...@li... > > https://lists.sourceforge.net/lists/listinfo/xmljs-users > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by OSTG. Have you noticed the changes on > Linux.com, ITManagersJournal and NewsForge in the past few weeks? Now, > one more big change to announce. We are now OSTG- Open Source Technology > Group. Come see the changes on the new OSTG site. www.ostg.com > _______________________________________________ > xmljs-users mailing list > xml...@li... > https://lists.sourceforge.net/lists/listinfo/xmljs-users > |