New topic: 

XML Load

<http://forums.realsoftware.com/viewtopic.php?t=46476>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        Dave_          Post subject: XML LoadPosted: Mon Jan 07, 2013 
3:17 pm                         
Joined: Wed Sep 15, 2010 1:48 pm
Posts: 70                Xml save works fine, the problem is how do I load what 
I have saved. 

This is the format, one node and the test uses 15 records. 

<?xml version="1.0" encoding="UTF-8" ?>
- <root>
<database_record message_number="1" uniqueID="L3Hr9X6p" category="Personal" 
notetext="I am using sheet protectors with my new palm. still learning how to 
write. some things never change - constant learning and relearning." 
permissions="0" />


This is the code... I get the node but do not know how to process it to get the 
individual records. I can dump the whole node, but can not seem to understand 
how to process it. 

Dim x As New XmlDocument(xmlText)
dim p as XmlAttribute
// check first node of document:
Dim n As XmlNode = x.FirstChild

MsgBox(n.Name) // doc node

msgbox("child count " + (str(n.ChildCount)))// using test file 15 was returned 
there are 15 records in the database
// and now walk over all sub nodes:

W_debug.run( n.ToString) // prints out a listing of all the records in root 
(all 15  test records)

for x = 1 to ( n.ChildCount)
  W_debug.run( n.Child(x).Name)
  W_debug.run( n.Child(x).Value)
  
next x
      
_________________
RS2012r2 Pro Win  
                             Top                jakuno          Post subject: 
Re: XML LoadPosted: Mon Jan 07, 2013 4:40 pm                         
Joined: Fri Aug 31, 2012 3:56 pm
Posts: 57                try:

Dim x As New XmlDocument(xmlText)
Dim p as XmlAttribute
Dim i as integer
Dim s as string

// check first node of document:
Dim n As XmlNode = x.FirstChild

MsgBox(n.Name) // doc node

msgbox("child count " + (str(n.ChildCount)))// using test file 15 was returned 
there are 15 records in the database
// and now walk over all sub nodes:

for i = 0 to n.ChildCount - 1
  s = n.Child(i).GetAttribute("message_number") + EndOfLine
  s = s + n.Child(i).GetAttribute("uniqueID") + EndOfLine
  s = s + n.Child(i).GetAttribute("category") + EndOfLine
  s = s + n.Child(i).GetAttribute("notetext") + EndOfLine
  s = s + n.Child(i).GetAttribute("permissions") + EndOfLine
  MsgBox s
next i
   
                             Top                timhare          Post subject: 
Re: XML LoadPosted: Mon Jan 07, 2013 5:03 pm                         
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11951
Location: Portland, OR  USA                Using attributes for your data is a 
bad idea.  A more well-formed XML would be
<database_record>
<message_number>1</message_number>
<uniqueID>L3Hr9X6p</uniqueID>
<category>Personal</category>
<notetext>I am using sheet protectors with my new palm. still learning how to 
write. some things never change - constant learning and relearning.</notetext>
<permissions>0</permissions>
</database_record>
   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to