New topic: 

Trying to understand advanced XML loading

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

         Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic          Author  
Message        Dave_          Post subject: Trying to understand advanced XML 
loadingPosted: Sat Feb 09, 2013 12:49 pm                         
Joined: Wed Sep 15, 2010 1:48 pm
Posts: 77                I finally got XML load and Save working 100% on a 
little program that converted about 1500 palm notes from an exported palm db 
file. 

Now I am working on a little database program that to loads and saves 
sqllite/realsqldatabase table information. I got the program to create the save 
xml output, but I am having problems understanding how to load the parsed XML 
output. 

The language reference  code examples are not very clear when parsing more 
complex XML. 

 <?xml version="1.0" encoding="UTF-8" ?>
- <root>
- <Database_Table>
- <Table_record>
<Database_Name>Woofy_Woof_7</Database_Name>
<Database_Heading>Heading Goes Here</Database_Heading>
- <Table_Fields>
- <Table_field>
<Table_Field_number>1</Table_Field_number>
<Fieldname>Dog_Biscuit</Fieldname>
<TheType>VarChar</TheType>
</Table_field>
- <Table_field>
<Table_Field_number>2</Table_Field_number>
<Fieldname>Amount</Fieldname>
<TheType>Integer</TheType>
</Table_field>
- <Table_field>
<Table_Field_number>3</Table_Field_number>
<Fieldname>Free_Samples</Fieldname>
<TheType>Integer</TheType>
</Table_field>
- <Table_field>
<Table_Field_number>4</Table_Field_number>
<Fieldname>Comment</Fieldname>
<TheType>Text</TheType>
</Table_field>
</Table_Fields>
</Table_record>
</Database_Table>
</root>


Root
 -Database table
  --Table record
  --Table name, other fields
  ---TableFields
 ----tablefield
     loop until all fields are loaded

This is the XML save code: 

 xml = New XmlDocument
// <?xml version="1.0" encoding="UTF-8"?>
root = xml.AppendChild(xml.CreateElement("root"))

// <?xml version="1.0" encoding="UTF-8"?><root/>
Database_Table = root.AppendChild(xml.CreateElement("Database_Table"))


Table_record = Database_Table.AppendChild(xml.CreateElement("Table_record"))

Database_Name = Table_record.AppendChild(xml.CreateElement("Database_Name"))
Database_Name.AppendChild(xml.CreateTextNode(TF_TableName.text))
'
Database_Heading = 
Table_record.AppendChild(xml.CreateElement("Database_Heading"))
Database_Heading.AppendChild(xml.CreateTextNode("Heading Goes Here"))

// loop through the database fields

Table_fields = Table_record.AppendChild(xml.CreateElement("Table_Fields"))


for x = 0 to mydbfields.Ubound
  
  Table_field = Table_fields.AppendChild(xml.CreateElement("Table_field"))
  
  Table_field_number = 
Table_field.AppendChild(xml.CreateElement("Table_Field_number")) // nil object 
exception // fixed
  Table_field_number.AppendChild(xml.CreateTextNode(str(x+1)))
  
  Fieldname = Table_field.AppendChild(xml.CreateElement("Fieldname"))
  fieldname.AppendChild(xml.CreateTextNode(mydbfields(x).Fieldname))
  
  TheType = Table_field.AppendChild(xml.CreateElement("TheType"))
  TheType.AppendChild(xml.CreateTextNode(mydbfields(x).Type))
  
  
  // <?xml version="1.0" encoding="UTF-8"?><root><person id="55"
  //active="true"/></root>
next x


I have noticed that dot notation does not work when your nestled in. I hope the 
new IDE has this fixed. 

Any Help would be wonderful on how to iterate the XML on load. This is the 
test, when I get it working 100% then I will add all of the fields.      
_________________
RS2012r2 Pro Win  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]      
-- 
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