Problem with XML

I am trying to put in root.AppendChild(xml.CreateElement("Benefactor") first Attribute the First Name, Family Name and Spouse Name, but I cannot.

Here’s the used code (derived from an LR example):

teamNode = root.AppendChild(xml.CreateElement("Benefactor")) teamNode.SetAttribute("Name", wMain.LB.Cell(0,0) + " " + wMain.LB.Cell(0,1) + " " + wMain.LB.Cell(0,2))

I only get the contents of Cell(0,0)… (First Name)

I tried:

teamNode = root.AppendChild(xml.CreateElement("Benefactor")) TheCell = wMain.LB.Cell(0,-1) TheCell = ReplaceAll(TheCell, Chr(9), " ") // Replace the Tab with a Space teamNode.SetAttribute("Name", TheCell)

This time it works, but I do not need to place the whole Row there: I will add each cell contents below the provided code as in:

teamNode = root.AppendChild(xml.CreateElement("Benefactor")) teamNode.SetAttribute("Name", wMain.LB.Cell(0,0) + " " + wMain.LB.Cell(0,1) + " " + wMain.LB.Cell(0,2)) // Put here the code to store each Cell contents as attribute // This works.

I worked to get code to export the Listbox contents (in a loop and save the contents to file), but I have this trouble. I wrote these simple lines (above) to try to find a solution to this problem, but I failed.

Idea ?

Try TheCell = wMain.LB.Cell(0,0) + " " + wMain.LB.Cell(0,1) + " " + wMain.LB.Cell(0,2) and examine the string in the debugger. Look at the byte values for any problems. You may have a stray Tab character in your data. (Hex 09)

Hi Tim,

I am unsure that I understand your answer 'it’s late here).

You are right for the case I used LB.Cell(0, -1): in the debugger I saw a hex 9 (strangely coded for Xojo). That is why I replaceAll.

For the two first lines of code (at the beinning), I used your sentence, but TheCell does only hold Cell(0,0) + one (or two ?) spaces, regardless of that appears in the real Cells. In my example, I have First Name, Family Name with real names, and Spouse Name is empty (it was a guy, not a gal).

I will re-read your answer by tomorrow morning after a cup of coffee, to be sure I am really awake.

Very strange. Try this:

dim TheCell, Cell0, Cell1, Cell2 as String
TheCell = wMain.LB.Cell(0, -1)
Cell0 = wMain.LB,Cell(0,0)
Cell1 = wMain.LB,Cell(0,1)
Cell2 = wMain.LB,Cell(0,2)
Break

Do you have any “hidden” columns (width set to 0)?
How many tab characters (hex 09) are there in TheCell between First Name and Family Name?

Not strange at all. Hex 09 is the standard ASCII value for a Tab character. When you use -1 for the column number, Listbox.Cell returns a tab-delimited string of the values for that row.

Hi Tim,

I will check your suggestions once back home.
Even now this looks strange: If I can get LB.Cell(0,0) text contents, I have to be able to get LB.Cell(0,1) 'cause the cell is filled with text

Strange in the unusual (for me) sense. I forgot, but maybe x7 (for Hex 7) ? It was the first time I saw a Tab coded in Xojo’s debugger.

Hi Tim, thank you for your answer.

I tried:

[code] Dim TheRow As String

// Display the whole line
TheRow = wMain.LB.Cell(0,-1)
TextArea1.Text = TheRow + EndOfLine + EndOfLine

// Display the Row, Cell after Cell
TextArea1.SelText = wMain.LB.Cell(0,0) + EndOfLine
TextArea1.SelText = wMain.LB.Cell(0,1) + EndOfLine
TextArea1.SelText = wMain.LB.Cell(0,2) + EndOfLine[/code]

and I get what I want.

Now, the real, wanted result in xml:

teamNode.SetAttribute("Name",  wMain.LB.Cell(0,0) + " " + wMain.LB.Cell(0,1) + " " + wMain.LB.Cell(0,2))

I also get what I want.

At last, I do not really understand why it does not worked yesterday (was I too tired ? Was it Xojo ? My MacBook Pro ? Whatever ?)

I found the problem in the real code. I use a variable for getting the data from the Cells. I do not reset this variable ! (I use it some lines after as a Column Index…

Thank you.