Results 1 to 4 of 4

Thread: XML String Problem

  1. #1

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    XML String Problem

    Hi,

    I am reading a XML string from a database and writing into a file. The problem is I have some fraction values in the database. Iam using MSXML parser to read the XML string and write it. But it converts all the fraction to date and writes to the file.
    For example if I have 5/8 in my XML string, it is written in file as 8-May.
    I even tried CStr, but it didn't work. AmI doing something wrong?
    I have given the code below.
    VB Code:
    1. strTempString = XMLDoc.childNodes(0).childNodes(j).childNodes(0).Text & "," & _
    2.             strPriceKey & "," & _
    3.             XMLDoc.childNodes(0).childNodes(j).childNodes(3).Text & "," & _
    4.             XMLDoc.childNodes(0).childNodes(j).childNodes(4).Text & "," & _
    5.             XMLDoc.childNodes(0).childNodes(j).childNodes(7).Text & "," & _
    6.             XMLDoc.childNodes(0).childNodes(j).childNodes(8).Text & "," & _
    7.             XMLDoc.childNodes(0).childNodes(j).childNodes(2).Text & "," & _
    8.             XMLDoc.childNodes(0).childNodes(j).childNodes(5).Text & "," & _
    9.             XMLDoc.childNodes(0).childNodes(j).childNodes(6).Text & "," & _
    10.             CStr(XMLDoc.childNodes(0).childNodes(j).childNodes(11).Text) & "," & _
    11.             XMLDoc.childNodes(0).childNodes(j).childNodes(10).Text & "," & _
    12.         XMLDoc.childNodes(0).childNodes(j).childNodes(9).Text
    13.         strFileArray(j) = strTempString
    14.         intFnum = FreeFile
    15.         Open strFilename For Output Lock Write As #intFnum
    16.         For i = 0 To UBound(strFileArray)
    17.             Print #intFnum, strFileArray(i)
    18.         Next i
    19.         Erase strFileArray
    20.         Close #intFnum
    In the above code
    CStr(XMLDoc.childNodes(0).childNodes(j).childNodes(11).Text)
    is the fractional part.

    Thanks,
    Pres

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    In the code where you read xml text, put a breakpoint on the line and see if the fraction is still there or if xml has already converted it to a date. If it is already converted and you can control how the xml is stored in the database, put CDATA tags around the data like below and see if that fixes the problem.

    ![CDATA[This is 5/8]]

  3. #3

    Thread Starter
    Addicted Member MrPresident2k's Avatar
    Join Date
    May 2002
    Location
    INDIA
    Posts
    167

    Thanks

    Thanks for replying,

    I tried that and while reading the XML, it was in fraction. The problem was with the Excel. When ever excel reads a fraction, it always taked it as a date. The solution I found out is that, on adding space before the fraction makes it read as a fraction and not as a date. Say instead of '5/8' Iam inserting ' 5/8' in the file.

    Thanks,
    Pres.

  4. #4

Posting Permissions

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



Click Here to Expand Forum to Full Width