Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / March 2008



Tip: Looking for answers? Try searching our database.

Problem with complex XML

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pijus - 06 Mar 2008 21:21 GMT
Hi!
I have a problem that for some will be trivial, but for me it is getting on my
nervs.
All the tutorials and tips I have seen around about AS2 and XML are based on
very simple XML sintax done in purpose for flash, but when the XMl is a little
complicated things doesn't work for me...
I have an XML that looks something like:
[CODE]
<content>
<values name="">
<numbers type="" name="" mode="" / >
<shapes  color="" size="" style=""/ >
</values>
<values name="">
<members city="" pets="" model="" / >
<questions  first="" second="" third="" / >
<problems difficulty="" / >
</values>
</content>
[/CODE]
As you see, values are different everytime, how can I access them?
Will a loop work in this structure?
THANK'S A LOT FOR YOUR HELP
Nancy - 14 Mar 2008 15:10 GMT
And this validates?  It doesn't look like well formed XML to me .. it has to
be valid XML or you're asking for trouble from the getgo.

Signature

Nancy Gill
Adobe Community Expert
Author:  Dreamweaver 8 e-book for the DMX Zone
Co-Author:  Dreamweaver MX: Instant Troubleshooter (August, 2003)
Technical Editor:  Dreamweaver CS3: The Missing Manual,
DMX 2004: The Complete Reference,  DMX 2004: A Beginner's Guide
Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP Web Development

> Hi!
> I have a problem that for some will be trivial, but for me it is getting
[quoted text clipped - 22 lines]
> Will a loop work in this structure?
> THANK'S A LOT FOR YOUR HELP
miquael - 19 Mar 2008 02:44 GMT
Look like fine XML to me ...

I am also having problems with XML parsing.  And I have had success with very
simple XML, for example, with this XML:

<?xml version="1.0" encoding="UTF-8"?>
<items>
<item id="0" title="0, 0" type="1" contentPath="sample.html">
<description>Description here.</description>
<georss>0 0</georss>
</item>
<item id="1" title="New York City" type="2" contentPath="sample.flv">
<description>Description here.</description>
<georss>42.3583 -75.85</georss>
</item>
<item id="2" title="Rome" type="3" contentPath="sample.html">
<description>Description here.</description>
<georss>41.54 -12.27</georss>
</item>
</items>

I can use this, and it will parse the above XML (which is then handled as
independent objects per <item> in the Node class):

public function processMarkerData (xmlData:XML):void {
            // loop through all markers in the XML
            // and generate a node for each one
            trace ("xmlData: " + xmlData);
            for each (var xmlPlacemark:XML in xmlData.item) {  
               
                trace ("success!");
               
                // create node
                var node:Node = new Node(
                            xmlPlacemark,
                            {
                            nodeID:    nodeID,
                            app:    this
                        });
           
            }
        }
miquael - 19 Mar 2008 02:48 GMT
But when I change the structure a little, this won't work!  Why not?   I just
want to create one Node for each <placemark> tag in the xml.

The XML:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
  <Placemark id="0" type ="1">
    <name>Zero - zero</name>
    <description>This is at zero latitude and zero longitude</description>
    <Point>
      <coordinates>0,0,0</coordinates>
    </Point>
  </Placemark>
 
    <Placemark id="1" type ="2">
    <name>Simple placemark</name>
    <description>Attached to the ground. Intelligently places itself
       at the height of the underlying terrain.</description>
    <Point>
      <coordinates>-122.0822035425683,37.42228990140251,0</coordinates>
    </Point>
  </Placemark>
 
    <Placemark id="2" type ="3">
    <name>New York City</name>
    <description>This is a rockin' town</description>
    <Point>
      <coordinates>42.3583,-75.85,0</coordinates>
    </Point>
  </Placemark>
</kml>

Yet, I cannot even get the second "success!" trace.   It's almost exactly the
same as above!  (xmlData.item vs. xmlData.Placemark)

Attach Code

public function processMarkerData (xmlData:XML):void {

    // loop through all markers in the XML
    // and generate a node for each one
    trace ("xmlData: " + xmlData);

    for each (var xmlPlacemark:XML in xmlData.Placemark) {
               
        trace ("success!");
               
        // create node
        var node:Node = new Node(
                    xmlPlacemark,
                    {
                    nodeID:    nodeID,
                    app:    this
                       });
               
        }
    }
}
miquael - 19 Mar 2008 02:51 GMT
So in this case, the children are equal, but the loop still does not work ...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.