Damn, I forgot to attach the xml file... p.s.: read my mail, if you don't want to read huge mail and a lot of explanations, then skip that part...
KKRT On Fri, Sep 08, 2006 at 11:42:00PM -0400, Youness Alaoui wrote: > Hello all... > I just love SOAP requests!!! the most annoying thing is the authentication, > but now that it's all done, it should be fairly easy to add > new stuff... like msn spaces.. it's been so long awaited but it's finally > here!!! > well.. not completly.. the protocol part is done, we still need the GUI part > + a little XML parsing magic... as I said in my commit log, > I'll send a msg here to explain the XML and how to use the Xml parsing > functions... well, it's simple.. in the attached mail, I've put > an XML file returned by ::MSNCCARD::getContactCard $email ... I hope that > user won't mind... I cropped some of the info... anyways, I ask > for 2 elements, and he has two elements, one is the 'myspace', the second is > his album... he also might have had a blog... anyways, each > element has some some info about it.. first, it's type as an attributes, then > as entries : title, url and totalNewItems ... it can also > have subelements... each subelement has as attributes a type and a > lastUpdated field... it also has a description, title, tooltip, and url > tags.. depending on the type of subElement (in the attached example, it's a > Photo from an Album element) we can have a thumbnailUrl, > webReadyUrl and albumName entries... > To access all those informations using the Xml APIs I wrote, it's easy... you > have only 3 APIs : > GetXmlNode > GetXmlEntry > GetXmlAttributes > > ok.. they all take as argument an xml list... so when you have your xml as > string, do a : > set list [xml2list $xml] > then call the APIs.. first one, GetXmlNode takes an xml list and a node path > and returns a list representing that node.. example : > set x [GetXmlNode [xml2list {<node1> <node2> <node3> hello </node3> </node2> > </node1}] "node1:node2:node3"] > puts "[list2xml $x]" > would print something like : "<node3>hello</node3>" > > now, as you saw, the 'node path' is a ':' separated list of tag names... the > same syntax as sxml... simple! :) > Now let's see... assuming you have <node1> <node2 /> <node2 /> <node2> I want > this one </node2> </node1> > you can get that 3rd one by calling : > GetXmlNode $xml "node1:node2" 2 > (first index starts at 0) > now, the same for GetXmlEntry, only it returns the content's of a node, so on > the previous xml, a [GetXmlEntry $xml "node1:node2" 2] would > return "I want this one", you can also specify which element you want by > adding the index number (optional) in the end... > the same principle applies for GetXmlAttribute... > > Now for the attached Xml, you can use some simple combinations of > GetXmlNode/Entry/Attribute to get everything you want... you should be > able to get anything using the getXmlEntry API, but the GetXmlNode might > become handy if you need a specific element.. example, you have > many subElements, in both <element> and you don't know which index it starts > for the album.. so you can do a GetXmlNode to get the > "element" tag, then do a GetXmlAttribute to get the type of the element, once > you get the album, you do a GetXmlNode to get each > subelement of the node, then you work with it with GetXmlEntry ... > Here's an example so you can understand it better : > : set xml [::MSNCCARD::getContactCard [EMAIL PROTECTED] > : set list [xml2list $xml] > : GetXmlAttribute [GetXmlNode $list > "soap:Envelope:soap:Body:GetXmlFeedResponse:GetXmlFeedResult:contactCard:elements:element" > 0] ":element" type > SpaceTitle > : GetXmlAttribute [GetXmlNode $list > "soap:Envelope:soap:Body:GetXmlFeedResponse:GetXmlFeedResult:contactCard:elements:element" > 1] ":element" type > Album > : GetXmlEntry $list > "soap:Envelope:soap:Body:GetXmlFeedResponse:GetXmlFeedResult:contactCard:elements:element:title" > Mathieu's space > : GetXmlEntry $list > "soap:Envelope:soap:Body:GetXmlFeedResponse:GetXmlFeedResult:contactCard:elements:element:url" > http://tchatcho84.spaces.live.com/?owner=1 > > etc.... it's a combination of GetXMlNode, GetXmlEntry and GetXmlAttribute... > your job to parse that now... you see why I didn't want to > parse it.. then I'd put it in an array and it would be complicated.. while I > think all the data in there is related to the GUI and it > should be parsed at the same time as the GUI is being built... > > Have fun!!! and good luck!!! > now.. what should I code next... ^o) > KaKaRoTo > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Amsn-devel mailing list > Amsn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/amsn-devel
ccard.xml
Description: application/xml
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________ Amsn-devel mailing list Amsn-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amsn-devel