Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


XML file read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-02-2007, 10:13 AM
Newbie
 
Join Date: Nov 2007
Posts: 9
Default XML file read

Is there any way to read xml files with basic4ppc;
Reply With Quote
  #2 (permalink)  
Old 12-02-2007, 11:03 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by stratus View Post
Is there any way to read xml files with basic4ppc;
Reading them is easy. They are just text files so open them with FileOpPen and read each line with FileRead.

Parsing them is a different matter. You will have to write that yourself!
Reply With Quote
  #3 (permalink)  
Old 12-02-2007, 04:01 PM
Newbie
 
Join Date: Nov 2007
Posts: 9
Default

Quote:
Originally Posted by agraham View Post
Reading them is easy. They are just text files so open them with FileOpPen and read each line with FileRead.

Parsing them is a different matter. You will have to write that yourself!
Yes i mean parse the xml file.
Reply With Quote
  #4 (permalink)  
Old 12-03-2007, 02:25 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi stratus,

Please have a look at help for the regex library.

And then at this...
http://www.regular-expressions.info/examples.html
"Grabbing HTML Tags"

This expression can be used for parsing XML tags, too.
Reply With Quote
  #5 (permalink)  
Old 12-03-2007, 02:49 PM
Newbie
 
Join Date: Nov 2007
Posts: 9
Default

Quote:
Originally Posted by alfcen View Post
Hi stratus,

Please have a look at help for the regex library.

And then at this...
http://www.regular-expressions.info/examples.html
"Grabbing HTML Tags"

This expression can be used for parsing XML tags, too.
Very useful.Thank's
Reply With Quote
  #6 (permalink)  
Old 12-03-2007, 03:22 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

You are welcome. If you prefer conventional methods, data embraced in an XML tag can be parsed like this:

Code:
url = ParseXML(x, "<url>", "</url>")

Sub ParseXML(p, t1, t2)
  'Extracts a string embraced in t1 an t2 tags
  Dim l, r1, r2
  l = StrLength(t1)
  r1 = StrIndexOf(p, t1, 0)
  If r1 > 0 Then  'if the start tag is found then...
    r2 = StrIndexOf(p, t2, r1 + 1)  'look for the end tag
    p = SubString(p, r1 + l, r2 - r1 - l)  'extract the string between the tags
    Return p  'Return the wanted string
  End If	
End Sub
This would extract an URL embraced in, for example <url>http://www.server.com/</url> tags.
x is the string obtained with

Code:
FileOpen(c1,"myfile.xml")
x = FileReadToEnd (c1)
FileClose(c1)
Best luck!
Robert
Reply With Quote
  #7 (permalink)  
Old 06-14-2008, 04:58 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 84
Default XML Parsing

I'm writing a program that retrieves weather data from one of the web services at webservicex.net; it sends an xml stream that contains single value tags (location data) and nested tags (for weather data)

This is the web service that I'm using: WebserviceX.NET :: Web Services

An XML reader library would be helpful, but until there is one I'm trying to use the Regex library to do it.

Attached is a work-in-progress that I put together to test extracting string(s) from an XML stream. Anyone else working with XML data?
Attached Files
File Type: sbp xmlTest.sbp (3.0 KB, 16 views)
Reply With Quote
  #8 (permalink)  
Old 06-15-2008, 04:52 AM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi digitaldon37,

Thanks a lot for sharing this.

Attached please find code for global weather retrieved from the same source.
It employs only one library, namely http.dll.

Country names and cities may need to be checked against
WebserviceX.NET :: Web Services

I still prefer Wunderground's weather data, which in my believe is most
accurate, but unfortunately, not available in XML.
Example is here: alfcen - tenki

Cheers
Robert
Attached Images
File Type: jpg wx1.jpg (15.0 KB, 27 views)
File Type: jpg wx2.jpg (16.0 KB, 22 views)
Attached Files
File Type: zip wxtest.zip (31.2 KB, 20 views)
Reply With Quote
  #9 (permalink)  
Old 06-20-2008, 04:03 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 84
Default Thanks for the XML examples

alfcen, thanks for the XML example. I looked at your web site and saw that you have quite a few apps written in b4ppc.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to read text file. ikaplan Questions & Help Needed 8 11-04-2008 04:36 PM
read Exel file? Byak@ Questions & Help Needed 2 10-21-2008 11:30 AM
Struggle to read a .txt file into TextBox? HARRY Questions & Help Needed 2 02-26-2008 05:39 PM
CSV file read still slow in V6.01 but other tasks much improved HarleyM Questions & Help Needed 3 01-27-2008 11:18 AM
How to know if a PM was read!? Cableguy Forum Discussion 0 05-12-2007 10:17 PM


All times are GMT. The time now is 05:58 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0