XML Whitespace generation and specific tags

Hi all,
I’m new to XML and am finding the xml libraries very powerful but a little confusing for my application. I guess it’s just because I don’t understand the terminology specific to what I’m trying to do.

Basically I’m trying to replicate the following packet:

???<?xml version="1.0" encoding="utf-8"?> ?? ERX Message! Free config!?? ?? ?? ?? ?? 125?? ??

The issue I’m having is that certain bytes and elements are not easy to replicate?

ie, how do I add the:

ERX Message! Free config!

The rest of the lines are fine such as:

Sen = root.AppendChild(xml.CreateElement(“RKorr”))
Sen.SetAttribute(“X”, “0”)
Sen.SetAttribute(“Y”, “0”)
Sen.SetAttribute(“Z”, “0”)
Sen.SetAttribute(“A”, “0”)
Sen.SetAttribute(“B”, “0”)
Sen.SetAttribute(“C”, “0”)

The other issue I have is that I can’t replicate the generated whitespace (i.e. carriage returns and line feeds as seen in the attached hex dump of the file.

For example the first three bytes? I’m not even sure what they are supposed to be!

EF BB BF 3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31 2E 30 22 20 65 6E 63 6F 64 69 6E 67 3D 22 75 74 66 2D 38 22 3F 3E 3C 53 65 6E 20 54 79 70 65 3D 22 49 6D 46 72 65 65 22 3E 20 20 20 0D 0A 20 20 20 3C 45 53 74 72 3E 45 52 58 20 4D 65 73 73 61 67 65 21 20 46 72 65 65 20 63 6F 6E 66 69 67 21 3C 2F 45 53 74 72 3E 0D 0A 20 20 20 3C 52 4B 6F 72 72 20 58 3D 22 30 22 20 59 3D 22 30 22 20 5A 3D 22 30 22 20 41 3D 22 30 22 20 42 3D 22 30 22 20 43 3D 22 30 22 20 2F 3E 0D 0A 20 20 20 3C 41 4B 6F 72 72 20 41 31 3D 22 30 22 20 41 32 3D 22 30 22 20 41 33 3D 22 30 22 20 41 34 3D 22 30 22 20 41 35 3D 22 30 22 20 41 36 3D 22 30 22 20 2F 3E 0D 0A 20 20 20 3C 45 4B 6F 72 72 20 45 31 3D 22 30 2E 30 30 30 30 22 20 45 32 3D 22 30 2E 30 30 30 30 22 20 45 33 3D 22 30 2E 30 30 30 30 22 20 45 34 3D 22 30 2E 30 30 30 30 22 20 45 35 3D 22 30 2E 30 30 30 30 22 20 45 36 3D 22 30 2E 30 30 30 30 22 20 2F 3E 0D 0A 20 20 20 3C 54 65 63 68 20 54 32 31 3D 22 31 2E 30 39 22 20 54 32 32 3D 22 32 2E 30 38 22 20 54 32 33 3D 22 33 2E 30 37 22 20 54 32 34 3D 22 34 2E 30 36 22 20 54 32 35 3D 22 35 2E 30 35 22 20 54 32 36 3D 22 36 2E 30 34 22 20 54 32 37 3D 22 37 2E 30 33 22 20 54 32 38 3D 22 38 2E 30 32 22 20 54 32 39 3D 22 39 2E 30 31 22 20 54 32 31 30 3D 22 31 30 2E 30 30 22 20 2F 3E 0D 0A 20 20 20 3C 44 69 4F 3E 31 32 35 3C 2F 44 69 4F 3E 0D 0A 20 20 20 3C 49 50 4F 43 3E 34 32 31 39 36 33 37 35 37 36 3C 2F 49 50 4F 43 3E 0D 0A 3C 2F 53 65 6E 3E

Thanks heaps,
James

The first three bytes are a BOM marker saying the rest of the data is UTF-8 http://en.wikipedia.org/wiki/Byte_order_mark
The rest of the XML is separated by CR-LF pairs

Sending the BOM marker is easy enough - just prepend it to the generated XML string
IF this is truly XML the CR-LF should NOT be relevant at all - unless the system you’re sending this to is dependent on them

Thanks Norman. That makes sense:)

I’ve used xml.transform to get the correct whitespace line endings (not quite the same as C# in that there are a few less char(20) characters (spaces) but hopefully close enough.

What I am finding is that when I send it out of a TCP socket as required, it’s working fine on a Windows machine, but not under Yosemite. Is there anything else I’m missing that could possibly be platform dependent?

I’ve tried setting encoding, and end of line to windows on OS X.

I have notices using wireshark that on OS X every TCP transfer is ack’d where as on Windows the ack comes through every 60 or so packets. The packets themselves look identical. Is there anything that might explain this?

Cheers,
J

The data is the same and one works & one doesn’t ?
The only thing I can think of would be line ending differences where OS X uses LF (&h0A) and Windows uses CRLF (&h0D &h0A)

Thanks Norman,

I suspected the same too and set the line endings etc to match. I’m pretty sure it’s something to do with the socket or OS X as I’ve tried outputting pure bytes (As per chrb(&hXX) and checked with wireshark to see that the packets are being sent the same between windows and OS X and they are.

The only difference is that on OS X, I’m sending an ACK for each packet i receive (I send once I’ve got data from the server) where as on Windows the ACK happens every 60 or so receives (TCP socket).

Any suggestions?

Cheers,
J

I should point out that the Xojo Socket must have something to do with the amount of ACK’s sent as on a C# program on the PC, the Acks are every 60 or so, whereas with a Xojo App, on Windows, the Acks are very 12 or so… (but still working for my application on windows only).

ack frequency shouldn’t matter as thats not part of the data being sent / received
if that really does have an impact then I’m at a loss why it would make any difference