Easy XML, dot reader - SWiSHMax Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
Easy XML, dot reader
Category : SWiSHMax | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

Tired of siblings, nodes, childs etc ?
Most of users would probably say: Yes !


Is there any easyier way to read XML ?
Read this thread and see for yourself.

-

As much as I can see, most of users avoids to use XML couse it is not
quite friendly
so I tried to make it easy with dot reader, couse it is
fammiliar to most of swishmax users.

So, how it works ?

Suppose that you have XML file like this:

CODE

<?xml version="1.0" encoding="iso-8859-1"?>
<test>
<nodeOne>node-1</nodeOne>
<nodeTwo nodeTwoAttr1="node-2-Attr-1" nodeTwoAttr2="node-2-Attr-2">
<subnodeTwo1>sub-Node-2-1</subnodeTwo1>
<subnodeTwo2 subnodeTwo2Attr1="sub-Node-2-2-Attr-1" />
<subnodeTwo3 subnodeTwo3Attr1="sub-Node-2-3-Attr-1">sub-Node-2-3</subnodeTwo3>
</nodeTwo>
<nodeOne nodeOneAttr1="second-node-1-Attr-1">node-1-second-one</nodeOne>
<nodeOne nodeOneAttr1="third-node-1-Attr-1">node-1-third-one</nodeOne>
<nodeThree>
<subnodeThree1>
<subSubnodeThree11>sub-Sub-Node-3-1-1</subSubnodeThree11>
</subnodeThree1>
</nodeThree>
<nodeOne>fourth-node-1</nodeOne>
</test>


CODE

   var sourcefile="cbx-xml_dot_reader_test.xml";
   var xm = new XML();
   xm.load(sourcefile);
   xm.ignoreWhite=true;  


After XML is loaded to var xm, you can search it like this:

to retrieve nodeOne name
xm.test.nodeOne.nodNam()

to retrieve nodeOne value
xm.test.nodeOne.nodVal()


to retrieve nodeTwo name
xm.test.nodeTwo.nodNam()

to retrieve nodeTwo value
xm.test.nodeTwo.nodVal()

to retrieve name of 1st attribute in nodeTwo
xm.test.nodeTwo.attNam(1) or xm.test.nodeTwo.attNam() // couse 1st is default

to retrieve value of 1st attribute in nodeTwo
xm.test.nodeTwo.attNam(1) or xm.test.nodeTwo.attNam() // couse 1st is default


Also, you can retrieve nodes and values with numbers of their positions or
occurrence number, like this:

to retrieve name of 1st node
xm.test.__1.nodNam()

to retrieve value of 1st node
xm.test.__1.nodVal()

to retrieve name of 1st attribute in 2nd node
xm.test.__2.attNam(1)

to retrieve value of 1st attribute in 2nd node
xm.test.__2.attVal(1)

also you can retrieve it like this
xm.test.__2.__1.nodVal()
it is the same as
xm.test.nodeTwo.__1.nodVal()
or
xm.test.nodeTwo.subnodeTwo1.nodVal()

you can retrieve value of attribute by attribute name
xm.test.nodeTwo.attVal('nodeTwoAttr2')


etc ...

This prototype will read XML to any depth.


Now, pay attention that nodeOne appears 4 times, so if you want to retrieve
3rd occurrence of nodeOne, you should do this:

xm.test.nodeOne__3.nodNam()
xm.test.nodeOne__3.nodVal()


There are many possibilities to retrieve XML, and most of them you will find in
cbx-xml_dot_reader_test.swi file.


attached file: cbx-xml_dot_reader_demo.zip, contains:
1. cbx-xml_dot_reader_test.html // html file
2. cbx-xml_dot_reader_test.swi // source file that will load files 3 & 4 and will read XML.
2a.cbx-xml_dot_reader_test.swf // swf file that will load files 3 & 4 and will read XML.
3. cbx-xml_dot_reader_demo.swf // demo swf file with dot reader prototype
4. cbx-xml_dot_reader_test.xml // xml file with test content

note 1: all swf, xml and html files must be in the same folder for test.

note 2: cbx-xml_dot_reader_demo.swf will display "http://cybernetix.t35.com" in your
main movie, to avoid this read note 3.

that's it, happy SWiSHing wink.gif
Download Example


© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online