structs.go
changeset 5 faef59c8db05
parent 3 6121aa2f21b1
child 6 8e425e340ca1
--- a/structs.go	Sat Dec 24 11:18:52 2011 -0700
+++ b/structs.go	Sat Dec 24 13:11:36 2011 -0700
@@ -13,6 +13,7 @@
 	"io"
 	"os"
 	"regexp"
+	"strings"
 	"xml"
 )
 
@@ -62,6 +63,10 @@
 }
 var _ xml.Marshaler = &errText{}
 
+type Unrecognized struct {
+	XMLName xml.Name
+}
+
 func (jid *JID) String() string {
 	result := jid.Domain
 	if jid.Node != nil {
@@ -106,6 +111,26 @@
 	return buf.Bytes(), nil
 }
 
+func parseStream(se xml.StartElement) (*Stream, os.Error) {
+	s := &Stream{}
+	se = se.Copy()
+	for _, attr := range se.Attr {
+		switch strings.ToLower(attr.Name.Local) {
+		case "to":
+			s.to = attr.Value
+		case "from":
+			s.from = attr.Value
+		case "id":
+			s.id = attr.Value
+		case "lang":
+			s.lang = attr.Value
+		case "version":
+			s.version = attr.Value
+		}
+	}
+	return s, nil
+}
+
 func (s *StreamError) MarshalXML() ([]byte, os.Error) {
 	buf := bytes.NewBuffer(nil)
 	buf.WriteString("<stream:error>")