PDA

View Full Version : Programming Project (XML and VB.NET)



Pyro
2009-12-25, 10:08 PM
So winter break rolled around, and to keep myself occupied, have to decided to embark on coding project with VB.NET.

There's an IM application Trillian (http://en.wikipedia.org/wiki/Trillian_(software)) which connects to almost every chat network imaginable in one program as well as keeps conversation logs. Essentially, what I'm trying to do is create a program that can view these chat logs.

Trillian stores these logs as "xml files" (as well as in plain text, but those are rubbish), but the problem is that they're poorly formatted and I have no experience with manipulating xml files.

Here's a sample:

<session type="start" time="1232818706" medium="FACEBOOK" to="1191881127" from="FName1%20LName1"/>
<message type="incoming_privateMessage" time="1232818721" medium="FACEBOOK" to="FName1%20LName1" from="1191881127" from_display="FName2%20LName2" text="btw%2C%20the%20rave%20costs%20%245%20to%20get%20in"/>
<message type="outgoing_privateMessage" time="1232818727" medium="FACEBOOK" to="1191881127" from="FName1%20LName1" from_display="FName1%20LName1" text="Hmm%2E%2E%2E"/>

I want to be able to "grab" the information in quotes, but I have no idea where to start. It's possible to do it using indexing and substring methods, but it gets kinda messy, and the xml log files have lots of special character encoding, so I would rather not reinvent the wheel.

Swordgleam
2009-12-26, 01:58 AM
VB.NET has some built in stuff for handling XML. I hates it and it burns us, 'cause (as far as I can tell) there is no way to view what node(1).child(2).child(3) is except in the debugger. But it's probably your best option.

To compound your problem, that is really bad XML. If it were "good" XML, it would look more like this:

<session>
<type>start</type>
<time>1232818706</time>
<medium>FACEBOOK</medium>
</session>

So I'm not sure how much luck you'll have; when I was dealing with XML, it was KML, which is more like the above, and less with the extra properties. But there IS a way to do it. It's just annoying.

Edit: To add to that, I would call something an XMLNode, and then just muck about with the intellisense in Visual Studios until something that looks appropriate pops up.

I wish I could be slightly more helpful, but I don't have Visual Studios on this machine, so I can't check for myself.

Pyro
2009-12-26, 11:50 AM
I was contemplating writing another program that would reformat the log files, and I think that's going to be the best way. It's going to be a lot of extra work, but it'll be worthwhile in the end because I intend to use treeview to organize the conversations into a hierarchy by date. XML is pretty much perfect for that, and well...it's already halfway there.

It also turns out special characters in the text, for example "btw%2C%20the%20rave%20costs%20%245%20to%20ge t%20in," are actually encoded as Hex UTF-8, so hopefully something exists somewhere that will decode that for me.

This project is as much about becoming a better coder than actually creating a functional program, so wandering around VB.NET and trying to figure things out is the underlying goal.

Swordgleam
2009-12-26, 04:11 PM
If there isn't a script that decodes that stuff, or you'd rather write one yourself, I'd use regexes. It's always useful to know regexes. (I'm one of the people described by the quote, "Some people, when they have a problem, think 'I know, I'll use regular expressions!' Now they have two problems.)