Raw-Write to Stream? Flexible Packet creation/analysation?

Hello, I am working on a project that needs very raw access to the XML stream. I have two questions:

  1. for my send-to-xmpp-stream-console i need a way to push a String into the (out) stream. How to do this. If there is no other than creating a Packet from the string, how to parse the String into a Packet?

  2. for my not private namespaces i need a way to generate and analyse Packets in a very felxible way. in detail: i want to generate and analyse all packet elements, their children (elements, text…) and parameters myself. How can I do this? how can I iterate through the xml?

Hey,

Just create a class that extends IQ and implement methods to return what you want.

Basicly just implement this method:

public String getChildElementXML() {

StringBuilder buf = new StringBuilder();

buf.append("<").append(ELEMENT_NAME).append(" xmlns=’’").append(

NAMESPACE).append("’’>");

buf.append("<").append(this.type.name()).append(">");

buf.append(content);

buf.append("</").append(this.type.name()).append(">");

buf.append("</").append(ELEMENT_NAME).append(">");

return buf.toString();

}

Regards,

Thiago

Hello, sorry but your comment was not of much help, maybe my question was not exact enough:

Question 1: I have this:

// the string

String mySampleStringIreadFromTextControl = "

How do i get the value of myPersonalImportantParam when i received such a packet???

best regards…

Could you help me please? Is there no way to treat a packet like a DOM at least!?

Helo,

I´m pretty sure that our API is flexible enough.

Can you tell me what are you wanting to do. So I can maybe suggest another solution.

You can use packet.toXML() method to construct a DOM Document if you want.

But what we usally do is to use an IQ provider and parse the information using XMLPullParser.

Please can explain a little of your application? Whta it should do? What purpose? Etc…

Regards,

Thiago

barata7 wrote:

You can use packet.toXML() method to construct a DOM Document if you want.

Yes, but packet.toXML() throws away all information that Smack doesn’'t understand.

You can use packet.toXML() method to construct a DOM Document if you want.

Ok, and how do I do this? If I want to create such a not by default supported packet myself, how can i push it in the stream (as dom, or how do i load it into a smach Iq packet)???

But what we usally do is to use an IQ provider and parse the information using XMLPullParser.

And how can i do this? how can i pull my information from the package (namespace not supported in smack)???

How can i send my own string “”

best regards…

edrin wrote:

If I want to create such a not by default supported packet myself, how can i push it in the stream (as dom, or how do i load it into a smach Iq packet)???

You could simply create a new plugin and register it for that namespace.

As an example, you could look at my implementation of XEP-0085:

ChatStateNotifications.java

or XEP-0066:

OutOfBandDataExtension.java

And how can i do this? how can i pull my information from the package (namespace not supported in smack)???

See above, it works both ways.