Consulting

Results 1 to 3 of 3

Thread: excel to xml (problem with listed elements)

  1. #1
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    2
    Location

    excel to xml (problem with listed elements)

    Hi,

    I have a problem with the following piece of code:
    For t = 1 To j
    Set XMLElement = XMLDoc.createElement("Correspondance")

    Nodes = Split(sSgnMeasured, SIGNAL_DELIMITER)
    sSignal = Nodes(k)
    sVariabMat = Nodes(k + 1)

    Call XMLElement.setAttribute("Signal", sSignal)
    Call XMLElement.setAttribute("Var", sVar)
    Call XMLParent.appendChild(XMLElement)
    Next

    which should return something like:
    <Correspondance Signal="signal1" Var="signal1_M" />
    <Correspondance Signal="signal2" Var="signal2_M" />
    but it returns:
    <Correspondance Signal="signal2" Var="signal2_M" />
    <Correspondance Signal="signal2" Var="signal2_M" />
    (it just puts the last signal in).
    sSgnMeasured.......has the value of the item on which is clicked on, in the listbox.
    I used some MsgBox-es to see what is stored in sSignal and in sVariabMat, and they store the right values, but when I look in the xml file, it looks wrong.
    Please give me an idea of what I should change

    Regards,
    dori

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Have you got a workbook and other files we can use?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Feb 2008
    Posts
    2
    Location
    sSgnMeasured = .List(i) & " - " & .List(i) & "_M"

    sFile = ThisWorkbook.Path & "\default.xml"

    With Worksheets("Main")
    Set XMLDoc.documentElement = XMLDoc.createElement("Test")

    Set XMLParent = XMLDoc.createElement("M_En")
    Call XMLDoc.documentElement.appendChild(XMLParent)

    If j > 0 Then
    For t = 1 To j
    Set XMLElement = XMLDoc.createElement("Correspondance")

    Nodes = Split(sSgnMeasured, SIGNAL_DELIMITER)

    Signal= Nodes(k)
    sVariab= Nodes(k + 1)

    Call XMLElement.setAttribute("Signal", Signal)
    Call XMLElement.setAttribute("Var", sVariab)
    Call XMLParent.appendChild(XMLElement)
    Next
    End If

    Set XMLParent = XMLParent.parentNode
    XMLDoc.Save sFile
    End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •