Posted By: ZippyV | Sep 3rd @ 4:25 PM
page 1 of 1
Comments: 8 | Views: 471
ZippyV
ZippyV
Fired Up

I'm looking into XMPP at the moment. The protocol is basically about sending and retrieving data that is XML formatted. I've tried to read some data by deserializing it to a class but it doesn't work (attributes like xmlns or empty tags don't get deserialized).

 

For example:

<stream:features>

 <starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'>

  <required/>

 </starttls>

 <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>

  <mechanism>DIGEST-MD5</mechanism>

  <mechanism>KERBEROS_V4</mechanism>

  </mechanisms>

</stream:features>

What would be the best way to interpret this kind of XML?

W3bbo
W3bbo
The Master of Baiters

What's so hard about writing an XML parser compliant with the XMPP spec? The System.Xml classes just provide the basic plumbing for XML processing, the bulk of the work is still your responsibility.

 

Also, how were you serialising classes as XMPP XML?

Sven Groot
Sven Groot
My name has 9 letters. Coincidence? I think not...

You don't need to write a parser, just load it into an XDocument (or XmlDocument if pre-3.5) and go from there. Writing your own XML parser is not required.

TommyCarlier
TommyCarlier
I want my scalps!

You don't have to create your own parser: .NET already has that (XmlReader for low-level access, XDocument for higher-level). But of course I encourage you  to read my parser tutorial. Wink Learning new stuff is always fun.

exoteric
exoteric
I : Next<I>

Well, the XML processor is the metaparser, but I have come to love using XLinq. It's the easiest way to deal with XML. In combination with the XPath extensions.

 

Still, I'd be interested at looking at the XMPP schema and using a class generator tool to see the output. I don't know how these tools handle XML namespaces but I assume it's via CLR namespaces and attributes. An empty element (or the lack of it) would be the perfect match for a bool.

W3bbo
W3bbo
The Master of Baiters

By "XML Parser" I mean a class that interprets the state of an XmlDocument instance (for example). I guess "parser" isn't the right word, how about "processor"?

TommyCarlier
TommyCarlier
I want my scalps!

A class that interprets the state of an XML-document: an “interpreter”? I like the word interpreter, it sounds funny, especially when people have trouble pronouncing it.

W3bbo
W3bbo
The Master of Baiters

But in CS an "interpreter" is something that processes something as it reads it in, without having the full file/document/message in its state first, in which case it would be a "translator".

page 1 of 1
Comments: 8 | Views: 471
Microsoft Communities