views:

98

answers:

3

I’m after some C# code that will have the following methods that will return Xml as the result.

Search the Apple iTunes App store. If I pass it a name or partial name the function must return a list of possible search results or just one result if it is a perfect match.

Example shown below:

<App>

  <AppId>321564880</AppId>

  <Name>Doodle Clock - Clock A Doodle Do!</Name>

  <ReleaseDate>Released Sep 28, 2009</ReleaseDate>

  <Artist>YARG</Artist>

  <Description>Description of App</Description>

  <Copyright>© YARG Limited 2009</Copyright>

  <Price>$0.99</Price>

  <Category>Lifestyle</Category>

  <MainImageUrl><!—main App icon image urlà </ImageUrl>

  <ExtraImages>

       <!-- these will be the extra images you see in the App store other than the main application icon -->

       <ImageUrl> <!—url of extra image 1à</ImageUrl>

              <ImageUrl> <!—url of extra image 2à</ImageUrl>

              <ImageUrl> <!—url of extra image 3à</ImageUrl>

  </ExtraImages>

  <Version>Version: 1.1 (iPhone OS 3.0 Tested)</Version>

  <Size>1.5 MB</Size>

</App>
A: 

Hello,

You should use XPath in .NET: http://www.aspfree.com/c/a/.NET/Working-with-XPath-The-NET-Way/

Vitaliy Liptchinsky
can you provide me a sample script!?
can you give me the basics?
A: 

I would use XmlTextReader. It's the fastest way (though read-forward-only) - if you are maybe looking for speed. If not, XPath should do.

+2  A: 

Okay the best way to create xml file and parse and manipulate them is using XDocument,XElement,etc. Because they are enumerable which means you can use LINQ on them and that will help you a lot.

For example :

XElement element = new XElement("Persons",
                                new XElement("Person","John",
                                             new XAttribute("Id","1")),
                                new XElement("Person","Aaron",
                                             new XAttribute("Id",2))
                                )

returns

<Persons>
 <Person Id="1">John</Person>
 <Person Id="2">Aaron</Person>
</Person>

More information : System.Xml.Linq Namespace

If you are looking for speed, then you can use XMLReader and XMLWriter but you can't find the flexibility that System.Xml.Linq provides.

Braveyard
could you provide an entire c# funtion for this?
@SmartestVEGA, I would but I think what you are looking for is a dynamic list so whatever I wrote above, it would be meaningless.
Braveyard
please proide Aaron!!