This project is read-only.

Porting WBXML Library to Silverlight/Windows Phone

Jan 6, 2011 at 8:30 PM

I am working on porting this library to Windows Phone Silverlight (should work in standard silverlight too).  To do that, I had to change from XmlDocument to XDocument since only linq is available.  I would be willing to post what I have to share.  However, I am having some difficulty in getting the implementation to work right due to differences in the XML namespaces. 

Here is the XML to WBXML part: 


        private byte[] GetWbxmlFromXml(string xml)
        {
            //create new converter with our code pages
            WbXmlDocument wbxmlReqDoc = new WbXmlDocument();
            wbxmlReqDoc.VersionNumber = 1.3;
            wbxmlReqDoc.TagCodeSpace = new EasCodeSpace();
            wbxmlReqDoc.Load(xml);
            byte[] WbxmlReqInBytes = wbxmlReqDoc.GetBytes();
            return WbxmlReqInBytes;
        }

 The wbxmlreqdoc.load(xml) line does not work. It gets

Member 'System.Xml.Linq.XDocument.Load(string)' cannot be accessed with an instance reference; qualify it with a type name instead

If I change it to

 wbxmlReqDoc = WbXmlDocument.Load(xml);

I get

Cannot implicitly convert type 'System.Xml.Linq.XDocument' to 'EasTestWp.WbXmlDocument'. An explicit conversion exists (are you missing a cast?)

Here is my function for converting a WbXml byte stream to xml:

        private WbXmlDocument GetXmlFromWbXml(StreamReader respStream) 
        {
            WbXmlDocument wbxmlRespDoc = new WbXmlDocument();
            wbxmlRespDoc.VersionNumber = 1.3;
            wbxmlRespDoc.TagCodeSpace = new EasCodeSpace();                    
            //wbxmlRespDoc = wbxmlRespDoc.LoadBytes(new StringReader(sr.ReadToEnd());
            wbxmlRespDoc = (WbXmlDocument)WbXmlDocument.Load(new StringReader(respStream.ReadToEnd())); 
            //wbxmlRespDoc = wbxmlRespDoc.LoadBytes(respStream);
            return wbxmlRespDoc;
        }

I dont get a compile error, but dont think this is the right syntax to get the streamreader response stream into xml.
If you want the full class project posted, where should I do that?  Anyone have suggestions on the implementation issues?

Jan 19, 2014 at 6:29 PM
Hi - I just ran across this thread. Were you ever able to port to WP/XDocument?

Thanks,
-Matt