simple XML APPENDING problem


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: simple XML APPENDING problem

  1. #1
    scopee Guest

    simple XML APPENDING problem


    my script just aims to append a new child node (that has been read in from
    an html form) to an existing 3 tier (incl. root element) xml doc...i get
    a 500 error ...comment in the code below indicates where i suspect (but can't
    figure out why) problem exists...any help would be appreciated...TIA!
    <%
    Dim objXMLDoc
    Dim objParentNode
    Dim objNewEntry
    Dim objNewParentNode
    Dim objNewDateText
    Dim objNewBlurbText
    Dim objNewLink1Text
    Dim objNewLink2Text
    Dim objNewDateElement
    Dim objNewBlurbElement
    Dim objNewLink1Element
    Dim objNewLink2Element
    Dim newDate, newBlog, newLink1, newLink2

    Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    objXMLDoc.async = False
    objXMLDoc.load("blurb.xml")

    newDate = Request.Form("date")
    newBlog = Request.Form("blurb")
    newLink1 = Request.Form("link1")
    newLink2 = Request.Form("link2")

    Set objNewDateElement = objXMLDoc.createElement("date")
    Set objNewDateText = objXMLDoc.createTextNode(newDate)
    objNewDateElement.appendChild(objNewDateText)

    Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    objNewBlurbElement.appendChild(objNewBlurbText)

    Set objNewLink1Element = objXMLDoc.createElement("link1")
    Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    objNewLink1Element.appendChild(objNewLink1Text)

    Set objNewLink2Element = objXMLDoc.createElement("link2")
    Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    objNewLink2Element.appendChild(objNewLink2Text)

    Set objNewEntry = objXMLDoc.createElement("entry")
    objNewEntry.appendChild(objNewDateElement)
    objNewEntry.appendChild(objNewBlurbElement)
    objNewEntry.appendChild(objNewLink1Element)
    objNewEntry.appendChild(objNewLink2Element)

    Set objParentNode = objXMLDoc.documentElement

    'THIS IS LINE WHERE I THINK PROBLEM IS
    objParentNode.appendChild(objNewEntry)

    'code goes on to save the xml doc from here to end

  2. #2
    Russell Jones Guest

    Re: simple XML APPENDING problem

    Post the "blurb.xml" document -- without it, there's no way to know exactly
    where the error occurs. However, when I run the code in VB here's the
    result:

    1. You have one apparent typing error:
    > Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)


    There's no variable in your code named newBlurb -- you set newBlog, but
    never use it.

    2. The code crashes on the line you suspected, but it crashes because the
    objParentNode (set in the preceding line) is Nothing
    > objParentNode.appendChild(objNewEntry)


    I suspect the reason we're both getting the same result is that "blurb.xml"
    is not loaded. I can't load it because you didn't post it, so this is just a
    good guess. DOMDocuments don't raise a VB or ASP-trappable error; instead,
    you can check errors using the Parseerror property.
    You should always load XML documents like this:
    if not objXMLDoc.load("blurb.xml") then
    ' trap the error
    Response.write "Error loading blurb.xml. & "<br>" & "Reason: " &
    objXMLDoc.Parseerror.reason & "<br>" & _
    "Line: " & objXMLDoc.Parseerror.line & "<br>" & "Position: ": &
    objXMLDoc.Parseerror.linepos & "<br>"
    Response.end
    end if

    Finally, on the Web server, you should provide the full path and filename,
    for example:
    objXMLDoc.Load Server.MapPath(".") & "\blurb.xml"

    HTH

    Russell Jones
    Sr. Web Development Editor
    DevX.com



    "scopee" <scopee@mediaone.net> wrote in message
    news:3ad65ab7$1@news.devx.com...
    >
    > my script just aims to append a new child node (that has been read in from
    > an html form) to an existing 3 tier (incl. root element) xml doc...i get
    > a 500 error ...comment in the code below indicates where i suspect (but

    can't
    > figure out why) problem exists...any help would be appreciated...TIA!
    > <%
    > Dim objXMLDoc
    > Dim objParentNode
    > Dim objNewEntry
    > Dim objNewParentNode
    > Dim objNewDateText
    > Dim objNewBlurbText
    > Dim objNewLink1Text
    > Dim objNewLink2Text
    > Dim objNewDateElement
    > Dim objNewBlurbElement
    > Dim objNewLink1Element
    > Dim objNewLink2Element
    > Dim newDate, newBlog, newLink1, newLink2
    >
    > Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    > objXMLDoc.async = False
    > objXMLDoc.load("blurb.xml")
    >
    > newDate = Request.Form("date")
    > newBlog = Request.Form("blurb")
    > newLink1 = Request.Form("link1")
    > newLink2 = Request.Form("link2")
    >
    > Set objNewDateElement = objXMLDoc.createElement("date")
    > Set objNewDateText = objXMLDoc.createTextNode(newDate)
    > objNewDateElement.appendChild(objNewDateText)
    >
    > Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    > Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    > objNewBlurbElement.appendChild(objNewBlurbText)
    >
    > Set objNewLink1Element = objXMLDoc.createElement("link1")
    > Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    > objNewLink1Element.appendChild(objNewLink1Text)
    >
    > Set objNewLink2Element = objXMLDoc.createElement("link2")
    > Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    > objNewLink2Element.appendChild(objNewLink2Text)
    >
    > Set objNewEntry = objXMLDoc.createElement("entry")
    > objNewEntry.appendChild(objNewDateElement)
    > objNewEntry.appendChild(objNewBlurbElement)
    > objNewEntry.appendChild(objNewLink1Element)
    > objNewEntry.appendChild(objNewLink2Element)
    >
    > Set objParentNode = objXMLDoc.documentElement
    >
    > 'THIS IS LINE WHERE I THINK PROBLEM IS
    > objParentNode.appendChild(objNewEntry)
    >
    > 'code goes on to save the xml doc from here to end




  3. #3
    scopee Guest

    Re: simple XML APPENDING problem


    thanks SO much russell,

    well, here is the new processForm.asp code i posted before...without any
    typos (hopefully) and with your suggestions added...but i'm still internal
    server error 500 crashing...i have also posted "blurb.xml" below it...
    T.I.A.!!

    <html>
    <head></head>
    <body>
    <%
    Dim objXMLDoc
    Dim objParentNode
    Dim objNewEntry
    Dim objNewParentNode
    Dim objNewDateText
    Dim objNewBlurbText
    Dim objNewLink1Text
    Dim objNewLink2Text
    Dim objNewDateElement
    Dim objNewBlurbElement
    Dim objNewLink1Element
    Dim objNewLink2Element
    Dim newDate, newBlurb, newLink1, newLink2

    Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    objXMLDoc.async = False
    objXMLDoc.Load Server.MapPath(".") & "\blurb.xml"

    if not objXMLDoc.load("blurb.xml") then
    ' trap the error
    Response.write "Error loading blurb.xml. & "<br>" & "Reason: " &
    objXMLDoc.Parseerror.reason & "<br>" & _
    "Line: " & objXMLDoc.Parseerror.line & "<br>" & "Position: ": &
    objXMLDoc.Parseerror.linepos & "<br>"
    Response.end
    end if

    newDate = Request.Form("date")
    newBlurb = Request.Form("blurb")
    newLink1 = Request.Form("link1")
    newLink2 = Request.Form("link2")

    Set objNewDateElement = objXMLDoc.createElement("date")
    Set objNewDateText = objXMLDoc.createTextNode(newDate)
    objNewDateElement.appendChild(objNewDateText)

    Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    objNewBlurbElement.appendChild(objNewBlurbText)

    Set objNewLink1Element = objXMLDoc.createElement("link1")
    Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    objNewLink1Element.appendChild(objNewLink1Text)

    Set objNewLink2Element = objXMLDoc.createElement("link2")
    Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    objNewLink2Element.appendChild(objNewLink2Text)

    Set objNewEntry = objXMLDoc.createElement("entry")
    objNewEntry.appendChild(objNewDateElement)
    objNewEntry.appendChild(objNewBlurbElement)
    objNewEntry.appendChild(objNewLink1Element)
    objNewEntry.appendChild(objNewLink2Element)

    Set objParentNode = objXMLDoc.documentElement

    'THIS IS LINE WHERE I THINK PROBLEM IS
    objParentNode.appendChild(objNewEntry)

    'Save the XML document release object instances and end script from here
    on out

    'Next is blurb.xml

    <?xml version="1.0"?><entries><entry><date>04.10.01</date><blurb>four score
    and seven years</blurb> <link1>www.google.com</link1><link2>www.yahoo.com</link2></entry></entries>





    "Russell Jones" <arj1@northstate.net> wrote:
    >Post the "blurb.xml" document -- without it, there's no way to know exactly
    >where the error occurs. However, when I run the code in VB here's the
    >result:
    >
    >1. You have one apparent typing error:
    >> Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)

    >
    >There's no variable in your code named newBlurb -- you set newBlog, but
    >never use it.
    >
    >2. The code crashes on the line you suspected, but it crashes because the
    >objParentNode (set in the preceding line) is Nothing
    >> objParentNode.appendChild(objNewEntry)

    >
    >I suspect the reason we're both getting the same result is that "blurb.xml"
    >is not loaded. I can't load it because you didn't post it, so this is just

    a
    >good guess. DOMDocuments don't raise a VB or ASP-trappable error; instead,
    >you can check errors using the Parseerror property.
    >You should always load XML documents like this:
    >if not objXMLDoc.load("blurb.xml") then
    > ' trap the error
    > Response.write "Error loading blurb.xml. & "<br>" & "Reason: " &
    >objXMLDoc.Parseerror.reason & "<br>" & _
    > "Line: " & objXMLDoc.Parseerror.line & "<br>" & "Position: ": &
    >objXMLDoc.Parseerror.linepos & "<br>"
    > Response.end
    >end if
    >
    >Finally, on the Web server, you should provide the full path and filename,
    >for example:
    >objXMLDoc.Load Server.MapPath(".") & "\blurb.xml"
    >
    >HTH
    >
    >Russell Jones
    >Sr. Web Development Editor
    >DevX.com
    >
    >
    >
    >"scopee" <scopee@mediaone.net> wrote in message
    >news:3ad65ab7$1@news.devx.com...
    >>
    >> my script just aims to append a new child node (that has been read in

    from
    >> an html form) to an existing 3 tier (incl. root element) xml doc...i get
    >> a 500 error ...comment in the code below indicates where i suspect (but

    >can't
    >> figure out why) problem exists...any help would be appreciated...TIA!
    >> <%
    >> Dim objXMLDoc
    >> Dim objParentNode
    >> Dim objNewEntry
    >> Dim objNewParentNode
    >> Dim objNewDateText
    >> Dim objNewBlurbText
    >> Dim objNewLink1Text
    >> Dim objNewLink2Text
    >> Dim objNewDateElement
    >> Dim objNewBlurbElement
    >> Dim objNewLink1Element
    >> Dim objNewLink2Element
    >> Dim newDate, newBlog, newLink1, newLink2
    >>
    >> Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    >> objXMLDoc.async = False
    >> objXMLDoc.load("blurb.xml")
    >>
    >> newDate = Request.Form("date")
    >> newBlog = Request.Form("blurb")
    >> newLink1 = Request.Form("link1")
    >> newLink2 = Request.Form("link2")
    >>
    >> Set objNewDateElement = objXMLDoc.createElement("date")
    >> Set objNewDateText = objXMLDoc.createTextNode(newDate)
    >> objNewDateElement.appendChild(objNewDateText)
    >>
    >> Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    >> Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    >> objNewBlurbElement.appendChild(objNewBlurbText)
    >>
    >> Set objNewLink1Element = objXMLDoc.createElement("link1")
    >> Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    >> objNewLink1Element.appendChild(objNewLink1Text)
    >>
    >> Set objNewLink2Element = objXMLDoc.createElement("link2")
    >> Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    >> objNewLink2Element.appendChild(objNewLink2Text)
    >>
    >> Set objNewEntry = objXMLDoc.createElement("entry")
    >> objNewEntry.appendChild(objNewDateElement)
    >> objNewEntry.appendChild(objNewBlurbElement)
    >> objNewEntry.appendChild(objNewLink1Element)
    >> objNewEntry.appendChild(objNewLink2Element)
    >>
    >> Set objParentNode = objXMLDoc.documentElement
    >>
    >> 'THIS IS LINE WHERE I THINK PROBLEM IS
    >> objParentNode.appendChild(objNewEntry)
    >>
    >> 'code goes on to save the xml doc from here to end

    >
    >



  4. #4
    Russell Jones Guest

    Re: simple XML APPENDING problem

    It works fine in VB now. You're loading the blurb.xml file twice though,
    once error-trapped and once not.

    Russell

    "scopee" <scopee@mediaone.net> wrote in message
    news:3ad69194@news.devx.com...
    >
    > thanks SO much russell,
    >
    > well, here is the new processForm.asp code i posted before...without any
    > typos (hopefully) and with your suggestions added...but i'm still internal
    > server error 500 crashing...i have also posted "blurb.xml" below it...
    > T.I.A.!!
    >
    > <html>
    > <head></head>
    > <body>
    > <%
    > Dim objXMLDoc
    > Dim objParentNode
    > Dim objNewEntry
    > Dim objNewParentNode
    > Dim objNewDateText
    > Dim objNewBlurbText
    > Dim objNewLink1Text
    > Dim objNewLink2Text
    > Dim objNewDateElement
    > Dim objNewBlurbElement
    > Dim objNewLink1Element
    > Dim objNewLink2Element
    > Dim newDate, newBlurb, newLink1, newLink2
    >
    > Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    > objXMLDoc.async = False
    > objXMLDoc.Load Server.MapPath(".") & "\blurb.xml"
    >
    > if not objXMLDoc.load("blurb.xml") then
    > ' trap the error
    > Response.write "Error loading blurb.xml. & "<br>" & "Reason: " &
    > objXMLDoc.Parseerror.reason & "<br>" & _
    > "Line: " & objXMLDoc.Parseerror.line & "<br>" & "Position: ": &
    > objXMLDoc.Parseerror.linepos & "<br>"
    > Response.end
    > end if
    >
    > newDate = Request.Form("date")
    > newBlurb = Request.Form("blurb")
    > newLink1 = Request.Form("link1")
    > newLink2 = Request.Form("link2")
    >
    > Set objNewDateElement = objXMLDoc.createElement("date")
    > Set objNewDateText = objXMLDoc.createTextNode(newDate)
    > objNewDateElement.appendChild(objNewDateText)
    >
    > Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    > Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    > objNewBlurbElement.appendChild(objNewBlurbText)
    >
    > Set objNewLink1Element = objXMLDoc.createElement("link1")
    > Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    > objNewLink1Element.appendChild(objNewLink1Text)
    >
    > Set objNewLink2Element = objXMLDoc.createElement("link2")
    > Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    > objNewLink2Element.appendChild(objNewLink2Text)
    >
    > Set objNewEntry = objXMLDoc.createElement("entry")
    > objNewEntry.appendChild(objNewDateElement)
    > objNewEntry.appendChild(objNewBlurbElement)
    > objNewEntry.appendChild(objNewLink1Element)
    > objNewEntry.appendChild(objNewLink2Element)
    >
    > Set objParentNode = objXMLDoc.documentElement
    >
    > 'THIS IS LINE WHERE I THINK PROBLEM IS
    > objParentNode.appendChild(objNewEntry)
    >
    > 'Save the XML document release object instances and end script from here
    > on out
    >
    > 'Next is blurb.xml
    >
    > <?xml version="1.0"?><entries><entry><date>04.10.01</date><blurb>four

    score
    > and seven years</blurb>

    <link1>www.google.com</link1><link2>www.yahoo.com</link2></entry></entries>
    >
    >
    >
    >
    >
    > "Russell Jones" <arj1@northstate.net> wrote:
    > >Post the "blurb.xml" document -- without it, there's no way to know

    exactly
    > >where the error occurs. However, when I run the code in VB here's the
    > >result:
    > >
    > >1. You have one apparent typing error:
    > >> Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)

    > >
    > >There's no variable in your code named newBlurb -- you set newBlog, but
    > >never use it.
    > >
    > >2. The code crashes on the line you suspected, but it crashes because the
    > >objParentNode (set in the preceding line) is Nothing
    > >> objParentNode.appendChild(objNewEntry)

    > >
    > >I suspect the reason we're both getting the same result is that

    "blurb.xml"
    > >is not loaded. I can't load it because you didn't post it, so this is

    just
    > a
    > >good guess. DOMDocuments don't raise a VB or ASP-trappable error;

    instead,
    > >you can check errors using the Parseerror property.
    > >You should always load XML documents like this:
    > >if not objXMLDoc.load("blurb.xml") then
    > > ' trap the error
    > > Response.write "Error loading blurb.xml. & "<br>" & "Reason: " &
    > >objXMLDoc.Parseerror.reason & "<br>" & _
    > > "Line: " & objXMLDoc.Parseerror.line & "<br>" & "Position: ": &
    > >objXMLDoc.Parseerror.linepos & "<br>"
    > > Response.end
    > >end if
    > >
    > >Finally, on the Web server, you should provide the full path and

    filename,
    > >for example:
    > >objXMLDoc.Load Server.MapPath(".") & "\blurb.xml"
    > >
    > >HTH
    > >
    > >Russell Jones
    > >Sr. Web Development Editor
    > >DevX.com
    > >
    > >
    > >
    > >"scopee" <scopee@mediaone.net> wrote in message
    > >news:3ad65ab7$1@news.devx.com...
    > >>
    > >> my script just aims to append a new child node (that has been read in

    > from
    > >> an html form) to an existing 3 tier (incl. root element) xml doc...i

    get
    > >> a 500 error ...comment in the code below indicates where i suspect (but

    > >can't
    > >> figure out why) problem exists...any help would be appreciated...TIA!
    > >> <%
    > >> Dim objXMLDoc
    > >> Dim objParentNode
    > >> Dim objNewEntry
    > >> Dim objNewParentNode
    > >> Dim objNewDateText
    > >> Dim objNewBlurbText
    > >> Dim objNewLink1Text
    > >> Dim objNewLink2Text
    > >> Dim objNewDateElement
    > >> Dim objNewBlurbElement
    > >> Dim objNewLink1Element
    > >> Dim objNewLink2Element
    > >> Dim newDate, newBlog, newLink1, newLink2
    > >>
    > >> Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    > >> objXMLDoc.async = False
    > >> objXMLDoc.load("blurb.xml")
    > >>
    > >> newDate = Request.Form("date")
    > >> newBlog = Request.Form("blurb")
    > >> newLink1 = Request.Form("link1")
    > >> newLink2 = Request.Form("link2")
    > >>
    > >> Set objNewDateElement = objXMLDoc.createElement("date")
    > >> Set objNewDateText = objXMLDoc.createTextNode(newDate)
    > >> objNewDateElement.appendChild(objNewDateText)
    > >>
    > >> Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    > >> Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    > >> objNewBlurbElement.appendChild(objNewBlurbText)
    > >>
    > >> Set objNewLink1Element = objXMLDoc.createElement("link1")
    > >> Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    > >> objNewLink1Element.appendChild(objNewLink1Text)
    > >>
    > >> Set objNewLink2Element = objXMLDoc.createElement("link2")
    > >> Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    > >> objNewLink2Element.appendChild(objNewLink2Text)
    > >>
    > >> Set objNewEntry = objXMLDoc.createElement("entry")
    > >> objNewEntry.appendChild(objNewDateElement)
    > >> objNewEntry.appendChild(objNewBlurbElement)
    > >> objNewEntry.appendChild(objNewLink1Element)
    > >> objNewEntry.appendChild(objNewLink2Element)
    > >>
    > >> Set objParentNode = objXMLDoc.documentElement
    > >>
    > >> 'THIS IS LINE WHERE I THINK PROBLEM IS
    > >> objParentNode.appendChild(objNewEntry)
    > >>
    > >> 'code goes on to save the xml doc from here to end

    > >
    > >

    >




  5. #5
    scopee Guest

    Re: simple XML APPENDING problem


    hi russell

    ...i will continue to work this thingy until i can get the results you're
    getting...but at least now i know the processing script is running fine thanks
    to you! i really, really appreciate it. scopee.







    "Russell Jones" <arj1@northstate.net> wrote:
    >It works fine in VB now. You're loading the blurb.xml file twice though,
    >once error-trapped and once not.
    >
    >Russell
    >
    >"scopee" <scopee@mediaone.net> wrote in message
    >news:3ad69194@news.devx.com...
    >>
    >> thanks SO much russell,
    >>
    >> well, here is the new processForm.asp code i posted before...without any
    >> typos (hopefully) and with your suggestions added...but i'm still internal
    >> server error 500 crashing...i have also posted "blurb.xml" below it...
    >> T.I.A.!!
    >>
    >> <html>
    >> <head></head>
    >> <body>
    >> <%
    >> Dim objXMLDoc
    >> Dim objParentNode
    >> Dim objNewEntry
    >> Dim objNewParentNode
    >> Dim objNewDateText
    >> Dim objNewBlurbText
    >> Dim objNewLink1Text
    >> Dim objNewLink2Text
    >> Dim objNewDateElement
    >> Dim objNewBlurbElement
    >> Dim objNewLink1Element
    >> Dim objNewLink2Element
    >> Dim newDate, newBlurb, newLink1, newLink2
    >>
    >> Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    >> objXMLDoc.async = False
    >> objXMLDoc.Load Server.MapPath(".") & "\blurb.xml"
    >>
    >> if not objXMLDoc.load("blurb.xml") then
    >> ' trap the error
    >> Response.write "Error loading blurb.xml. & "<br>" & "Reason: " &
    >> objXMLDoc.Parseerror.reason & "<br>" & _
    >> "Line: " & objXMLDoc.Parseerror.line & "<br>" & "Position: ": &
    >> objXMLDoc.Parseerror.linepos & "<br>"
    >> Response.end
    >> end if
    >>
    >> newDate = Request.Form("date")
    >> newBlurb = Request.Form("blurb")
    >> newLink1 = Request.Form("link1")
    >> newLink2 = Request.Form("link2")
    >>
    >> Set objNewDateElement = objXMLDoc.createElement("date")
    >> Set objNewDateText = objXMLDoc.createTextNode(newDate)
    >> objNewDateElement.appendChild(objNewDateText)
    >>
    >> Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    >> Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    >> objNewBlurbElement.appendChild(objNewBlurbText)
    >>
    >> Set objNewLink1Element = objXMLDoc.createElement("link1")
    >> Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    >> objNewLink1Element.appendChild(objNewLink1Text)
    >>
    >> Set objNewLink2Element = objXMLDoc.createElement("link2")
    >> Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    >> objNewLink2Element.appendChild(objNewLink2Text)
    >>
    >> Set objNewEntry = objXMLDoc.createElement("entry")
    >> objNewEntry.appendChild(objNewDateElement)
    >> objNewEntry.appendChild(objNewBlurbElement)
    >> objNewEntry.appendChild(objNewLink1Element)
    >> objNewEntry.appendChild(objNewLink2Element)
    >>
    >> Set objParentNode = objXMLDoc.documentElement
    >>
    >> 'THIS IS LINE WHERE I THINK PROBLEM IS
    >> objParentNode.appendChild(objNewEntry)
    >>
    >> 'Save the XML document release object instances and end script from here
    >> on out
    >>
    >> 'Next is blurb.xml
    >>
    >> <?xml version="1.0"?><entries><entry><date>04.10.01</date><blurb>four

    >score
    >> and seven years</blurb>

    ><link1>www.google.com</link1><link2>www.yahoo.com</link2></entry></entries>
    >>
    >>
    >>
    >>
    >>
    >> "Russell Jones" <arj1@northstate.net> wrote:
    >> >Post the "blurb.xml" document -- without it, there's no way to know

    >exactly
    >> >where the error occurs. However, when I run the code in VB here's the
    >> >result:
    >> >
    >> >1. You have one apparent typing error:
    >> >> Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    >> >
    >> >There's no variable in your code named newBlurb -- you set newBlog, but
    >> >never use it.
    >> >
    >> >2. The code crashes on the line you suspected, but it crashes because

    the
    >> >objParentNode (set in the preceding line) is Nothing
    >> >> objParentNode.appendChild(objNewEntry)
    >> >
    >> >I suspect the reason we're both getting the same result is that

    >"blurb.xml"
    >> >is not loaded. I can't load it because you didn't post it, so this is

    >just
    >> a
    >> >good guess. DOMDocuments don't raise a VB or ASP-trappable error;

    >instead,
    >> >you can check errors using the Parseerror property.
    >> >You should always load XML documents like this:
    >> >if not objXMLDoc.load("blurb.xml") then
    >> > ' trap the error
    >> > Response.write "Error loading blurb.xml. & "<br>" & "Reason: " &
    >> >objXMLDoc.Parseerror.reason & "<br>" & _
    >> > "Line: " & objXMLDoc.Parseerror.line & "<br>" & "Position: ": &
    >> >objXMLDoc.Parseerror.linepos & "<br>"
    >> > Response.end
    >> >end if
    >> >
    >> >Finally, on the Web server, you should provide the full path and

    >filename,
    >> >for example:
    >> >objXMLDoc.Load Server.MapPath(".") & "\blurb.xml"
    >> >
    >> >HTH
    >> >
    >> >Russell Jones
    >> >Sr. Web Development Editor
    >> >DevX.com
    >> >
    >> >
    >> >
    >> >"scopee" <scopee@mediaone.net> wrote in message
    >> >news:3ad65ab7$1@news.devx.com...
    >> >>
    >> >> my script just aims to append a new child node (that has been read

    in
    >> from
    >> >> an html form) to an existing 3 tier (incl. root element) xml doc...i

    >get
    >> >> a 500 error ...comment in the code below indicates where i suspect

    (but
    >> >can't
    >> >> figure out why) problem exists...any help would be appreciated...TIA!
    >> >> <%
    >> >> Dim objXMLDoc
    >> >> Dim objParentNode
    >> >> Dim objNewEntry
    >> >> Dim objNewParentNode
    >> >> Dim objNewDateText
    >> >> Dim objNewBlurbText
    >> >> Dim objNewLink1Text
    >> >> Dim objNewLink2Text
    >> >> Dim objNewDateElement
    >> >> Dim objNewBlurbElement
    >> >> Dim objNewLink1Element
    >> >> Dim objNewLink2Element
    >> >> Dim newDate, newBlog, newLink1, newLink2
    >> >>
    >> >> Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
    >> >> objXMLDoc.async = False
    >> >> objXMLDoc.load("blurb.xml")
    >> >>
    >> >> newDate = Request.Form("date")
    >> >> newBlog = Request.Form("blurb")
    >> >> newLink1 = Request.Form("link1")
    >> >> newLink2 = Request.Form("link2")
    >> >>
    >> >> Set objNewDateElement = objXMLDoc.createElement("date")
    >> >> Set objNewDateText = objXMLDoc.createTextNode(newDate)
    >> >> objNewDateElement.appendChild(objNewDateText)
    >> >>
    >> >> Set objNewBlurbElement = objXMLDoc.createElement("blurb")
    >> >> Set objNewBlurbText = objXMLDoc.createTextNode(newBlurb)
    >> >> objNewBlurbElement.appendChild(objNewBlurbText)
    >> >>
    >> >> Set objNewLink1Element = objXMLDoc.createElement("link1")
    >> >> Set objNewLink1Text = objXMLDoc.createTextNode(newLink1)
    >> >> objNewLink1Element.appendChild(objNewLink1Text)
    >> >>
    >> >> Set objNewLink2Element = objXMLDoc.createElement("link2")
    >> >> Set objNewLink2Text = objXMLDoc.createTextNode(newLink2)
    >> >> objNewLink2Element.appendChild(objNewLink2Text)
    >> >>
    >> >> Set objNewEntry = objXMLDoc.createElement("entry")
    >> >> objNewEntry.appendChild(objNewDateElement)
    >> >> objNewEntry.appendChild(objNewBlurbElement)
    >> >> objNewEntry.appendChild(objNewLink1Element)
    >> >> objNewEntry.appendChild(objNewLink2Element)
    >> >>
    >> >> Set objParentNode = objXMLDoc.documentElement
    >> >>
    >> >> 'THIS IS LINE WHERE I THINK PROBLEM IS
    >> >> objParentNode.appendChild(objNewEntry)
    >> >>
    >> >> 'code goes on to save the xml doc from here to end
    >> >
    >> >

    >>

    >
    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center