IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

I've been doing some work recently that uses our LotusScript DOM classes, and I noticed what is probably not news to some of you, that apostrophes aren't correctly quoted when serializing from DOM, so that you can get something like this:

<thing description='Don't try this at home'>

This is of course not syntactically correct.

I have fixed the error, and future releases should not have this problem.

I also had occasion to want to insert a node in the middle of a list of sub-elements in the DOM structure, and this turned out to be harder to do than I thought it should be. I wrote the following subroutine, which does the trick, but it's not terribly efficient. Perhaps someone out there has a more ingenious technique.

Sub InsertNodeBefore(domdoc As NotesDOMDocumentNode, nodeSib As NotesDOMNode, nodeNew As NotesDOMNode)
        Dim parent As NotesDOMNode
        Set parent = nodeSib.ParentNode
        If parent.IsNull Then Error 18550, "Can't InsertNodeBefore node with no parent."
        Dim tempParent As NotesDOMNode
        Set tempParent = parent.Clone(False)
        Dim nodeNext As NotesDOMNode, nodeCur As NotesDOMNode
        Set nodeCur = nodeSib
        Do
                Set nodeNext = nodeCur.NextSibling
                tempParent.AppendChild nodeCur
                Set nodeCur = nodeNext
        Loop Until nodeCur.IsNull
       
        parent.AppendChild nodeNew
        Set nodeCur = tempParent.FirstChild
        Do
                Set nodeNext = nodeCur.NextSibling
                parent.AppendChild nodeCur
                Set nodeCur = nodeNext
        Loop Until nodeCur.IsNull
End Sub

Andre Guirard | 28 August 2007 02:27:44 PM ET | Plymouth, MN, USA | Comments (5)

Search this blog 

Disclaimer 

    About IBM Privacy Contact