children XML loadClip

loadClip does not... What is the reason for this:

trace (nodes Sublst.ChildNodes(1).ChildNodes(0) [1] .firstChild); / / images/IMG_01.jpg

loadClip (nodes
Sublst.ChildNodes(1).ChildNodes(0) [1] .firstChild, mc); does not work

loadClip ("images/IMG_01.jpg", mc); works


If I had to use loadMovie it would work... but I need to use loadClip because I need listeners.
In other words, if I used loadMovie, so I could just make a loop and loads all at the same time... but I need to load them one at a time, in order.

Wow this post was earlier
Since then, I learned a lot about xml, php, and how to use them with flash.
I ended up building the .xml differently in php file
attributes.URL used for the path.
Its funny watching this code now... I can't believe that it works.
Anyway, here is the part of the code very sloppy.

Tags: Adobe Animate

Similar Questions

  • Selection children XML with namespaces

    I'm trying to select children of an XML element nodes that have a different namespace of the parent, but xml.child (name) returns an empty list.

    In the attached code, londonList contains a single XML element and parisList is empty. I can't figure out how to find the child of paris and we tried to add the prefix to findParis (so it's "ff: b") as well as to transform an XML object with the name 'b' findParis to add namespace ff, then passing to the child. None of those who worked.

    Any help is appreciated.

    I found the solution. the child() method uses namespace by default to search for the element name. Because I couldn't understand how to specify a different namespace in the method call, just set default namespace before calling children to the namespace of the element.

  • Ordering children XML records

    Hello

    I have the following query that retrieves the records in order for a customer.

    SELECT XMLAGG)
    XmlElement ("customer",
    XmlAttributes (id, name)
    (select xmlagg)
    XmlElement ("Order",
    XmlAttributes (o.id AS "O.ID", o.odate as "date")))
    orders o
    where CUSTOMER.ID = O.CUSTID
    ),
    (select xmlagg)
    XmlElement ("Order",
    XmlAttributes (o1.id AS "O1.ID", o1.odate as "O1.date")
    ) )
    of new_orders o1
    where CUSTOMER.ID = O1. CUSTOMERID
    )
    )
    ).extract('/*') xml
    of the customer
    /


    Output
    ---------------------------------------------
    < customer ID = "100" NAME = "ANN" >
    < O.ID = "2000 order" date = "2010-02-10" / > "
    < O.ID = "6000 order" date = "2010-02-10" / > "
    < O.ID = "12000 order" date = "2010-02-10" / > "
    < O1.ID = "2000 to order' O1.date ="2010-02-10"/ >"
    < O1.ID = "6000 to order' O1.date ="2010-02-10"/ >"
    < O1.ID = "12000 to order' O1.date ="2010-02-10"/ >"
    < / customer >
    < customer ID = "300" NAME = 'JACK' >
    < O.ID = "9000 order" date = "2010-02-10" / > "
    < O1.ID = "9000 to order' O1.date ="2010-02-10"/ >"
    < / customer >

    I want to order records to be sorted by o.id and o1.id for an example of customer.for


    < customer ID = "100" NAME = "ANN" >
    < O.ID = "2000 order" date = "2010-02-10" / > "
    < O1.ID = "2000 to order' O1.date ="2010-02-10"/ >"

    < O.ID = "6000 order" date = "2010-02-10" / > "
    < O1.ID = "6000 to order' O1.date ="2010-02-10"/ >"

    < O.ID = "12000 order" date = "2010-02-10" / > "
    < O1.ID = "12000 to order' O1.date ="2010-02-10"/ >"
    < / customer >

    < customer ID = "300" NAME = 'JACK' >
    < O.ID = "9000 order" date = "2010-02-10" / > "
    < O1.ID = "9000 to order' O1.date ="2010-02-10"/ >"
    < / customer >


    The pointers will be appreciated.
    SQL> alter session set nls_date_format='yyyy-mm-dd'
    /
    Session altered.
    
    SQL> with customer as
    (
      select 100 id, 'ANN' name from dual union all
      select 300 id, 'JACK' from dual
    ),
     orders as
    (
      select 2000 id, 100 custid, date '2010-02-10' odate from dual union all
      select 6000 id, 100, date '2010-02-10' odate from dual union all
      select 9000 id, 300, date '2010-02-10' odate from dual union all
      select 12000 id, 100, date '2010-02-10' odate from dual
    ),
    new_orders as
    (
      select 2000 id, 100 custid, date '2010-02-10' odate from dual union all
      select 6000 id, 100, date '2010-02-10' odate from dual union all
      select 9000 id, 300, date '2010-02-10' odate from dual union all
      select 12000 id, 100, date '2010-02-10' odate from dual
    )
    --
    --
    select xmlagg (
              xmlelement ("Customer",
                          xmlattributes (id, name),
                          (select xmlagg (x order by id)
                             from (select custid, id, xmlelement ( "Order", xmlattributes (id "O.ID", o.odate as "date")) x from orders o
                                    union all
                                   select custid, id, xmlelement ("Order", xmlattributes (id "O1.ID", o.odate as "date")) from new_orders o) o
                            where customer.id = o.custid))).extract('/*') xml
      from customer
    /
    XML
    --------------------------------------------------------------------------------
    
      
      
      
      
      
      
    
    
      
      
                                                                         
    
    1 row selected.
    
  • XML: Apending children

    Let's say that the following XML:
    < list >
    < item > < / item >
    < item > < / item >
    < / list >

    Now in ActionScript, if I have to loop through all the children and you are trying to add text nodes in each node as for

    (pseudocode)

    children = xml.children ();
    for (i = 0; i < children.length (); ++ I)
    {
    children .appendChild ("test" + i);
    }

    What is happening here is the two nodes updated twice. It seems that the XML code adds the child to all nodes of the same name. So now my XML looks like this:

    < list >
    < element > test1 test2 < / item >
    < element > test1 test2 < / item >
    < / list >

    What I want to do is the following:
    < list >
    Test1 < item > < / item >
    Test2 < item > < / item >
    < / list >


    Is this possible or is the XML in ActionScript borked?

    Hmm, I see now that rather than managing multiple xml nodes, flex prefer to group similar nodes in a single table. I'm not particularly fond of that it goes against how to work with XML in other languages and platforms, but I can live with that for now.

    As a solution, I'm deleting duplicate nodes and instead adding children to the same kids over and over again. If the result is as follows:



    Item1
    Item2
    Item3
    ...

    In the action script, I have to do the following to access these text nodes:

    list.item.getChildren () [index];

    I guess that's not bad. He worked my way, the only difference would have been:

    List.Item [index]

    So, there is a further step involved. Maybe, I'll just write a wrapper which will do that for me.

    If anyone wants to share their comments on this, please do. Meanwhile I'll label has responded to this topic.

  • How to delete children nodes in Xml?

    Hello

    Say there is a set of xml nodes, and each node has a large number of child nodes. How eliminate us all the child nodes of a sudden... Y there, as in any method preset that is defined to do this... As far as I searched there was no method as node.clear () or node.removeall () as in .net!       I have seen node.removechild () but it asks for the name of the node that must be removed...

    Well, I have this requirement where I need to create an xml document. This happens by looping through a set of nodes in the 'for' loops and I needed to clear the children nodes present in each of them after the end of a particular inner loop. in any case I found a solution... I ve changed the way in which the nodes are created. So now I have not wory to this topic... But a clear() method would have been nice. This applies to all objects...

  • Bindable XML children - strange behavior

    Hi people, I met a strange problem and I'm completely stumped on it.

    I hope someone is able to help me with this.

    Here's my situation:

    I have a module mxml, that can be called "Module", which contains a [Bindable] variable protected XML, let's call it "selectedBeer" for reference. It is instantiated with null on the module creation, but full of XML if you click on some specific user interface features. In this XML file, there are two nodes XML children relevant to my problem - let's call them price and AlcoholContent.

    Now I have another module, call it "BeerChoosingModule", which stretches from "Module". He has, among others, two components of the spark NumericStepper. Here is the mxml:

    ...
    <s:HGroup verticalAlign="middle">
              <s:Label text="Selected blah's X:" />
              <s:NumericStepper snapInterval="0.01" stepSize="20" id="desiredPriceEditor" change="changeSelection(event)" minimum="0" maximum="99999" width="120"
                        valueParseFunction="this.PandACFormatter.parseNumber" valueFormatFunction="this.PandACFormatter.format" maxChars="10"
                        value="{this.selectedBeer== null ? 0 : this.PandACFormatter.parseNumber(this.selectedBeer.Price)}"/>
    </s:HGroup>
    <s:HGroup verticalAlign="middle">
              <s:Label text="Selected blah's Y:" />
              <s:NumericStepper snapInterval="0.01" stepSize="20" id="desiredAlcoholContentEditor" change="changeSelection(event)" minimum="0" maximum="99999" width="120"
                        valueParseFunction="this.PandACFormatter.parseNumber" valueFormatFunction="this.PandACFormatter.format" maxChars="10"
                        value="{this.selectedBeer== null ? 0 : this.PandACFormatter.parseNumber(this.selectedBeer.AlcoholContent)}"/>
    </s:HGroup>
    ...
    
    
    

    To the extent of the AlcoholContent and the price get used, they get used together and exactly the same way (i.e. If they are converted to a string for something, they both have, using exactly the same syntax, etc.)

    Now, the inexplicable behavior seems to occur to the link. If I try to change the value of the desiredPriceEditor in the user interface that the application is running, I can't change it's fine, and then the changeSelection (event) function works, assigns a new value to selectedBeer.Price manually and everything is hunkey dory. However, if I try to change the value for the desiredAlcoholContentEditor, as soon as testing of the user interface to make the change, it gets returned back to the original that. PandACFormatter.parseNumber (this.selectedBeer.AlcoholContent).

    Any ideas on what's going wrong here?

    Thanks for the reply.

    Yes, he would. However, in the situation that I have described, if the XML would change, it would change for the price and the AlcoholContent nodes at the same time. Nothing like that happens for the Price node. Now, in the changeSelection(event) function of what I do is something like:

    selectedBeer.Price= desiredPriceEditor . value.toString ()

    selectedBeer.AlcoholContent= desiredAlcoholContentEditor . value.toString ()

    Would it be possible that because I change the first price node, the binding is triggered for the purpose of any selectedBeer, so the desiredAlcoholContentEditor .value property is reset to this.PandACFormatter.parseNumber(this.selectedBeer.AlcoholContent) before the second line of the above code can even run?


  • XML question: How do I search for children without grandchildren

    With an XML document:

    var xml =

    < root >

    < name L1 = "First" >

    < garbage / >

    < / L1 >

    < name L1 = "Second" >

    < garbage / >

    < / L1 >

    < / root >

    I need a XMLList tags < L1 > without their children, then the output should be:

    < name L1 = "First" >

    < name L2 = "Second" >

    Can someone help me with the syntaxt actionscript to accomplish this XML query? I could not find an example that does not return the children of the < L1 > tags as well.

    Thank you

    David

    Well, if you need exact release, you could use this line:

    trace (xml.toXMLString (match) (/<\s*L1.*?>/g) .join ('\n'));

    This approach much faster that doing redundant xmlfiltering + removal of garbage, hope this helps

  • XML has children [whether or not he has]

    Hello guys

     <person name="Roshi">
              <children>
                   <person name="Roomi">
                        <children>
                             <person name="Andy"/>
                             <person name="Johny"/>
                        </children>
                   </person>
                   <person name="Hazy"/>
                   <person name="sunny"/>
              </children>
         </person>;
    

    When I use following code

    {if (XML. Child ("Children"))}

    trace ("he has children");

    } else {}

    trace ("there no");

    }

    But even she print 'there children' for foggy and Sunny who don't have no children

    I really want to make a comparison as

    Roshi has children

    Eric has children

    Andy's not children etc.

    Each loop works well, but I just need to make the comparison

    Please guide

    Thanks in advance

    This should help hopefully:

    //use a wrapper tag to provide access to the top leve person tag
    
    var xml:XML =
              
              
               
                 
                
                
                 
                
                 
                 
              
         
          ;
    
    //try not to use XMLLists as Boolean values, because they are not 'null' and therefore evaluate to true:
    
    if (xml.children.person.(@name=="Roomi")) trace('found Roomi, Great! (or did I?)')
    
    if (xml.children.person.(@name=="Room")) trace('found Room, Great! (or did I?)')
    
    //oh I see, so the XMLList evaluated as a Boolean is wrong...I need to check its length!!!!
    if (xml.children.person.(@name=="Roomi").length()) trace('found Roomi, Great! Now I\'m certain')
    
    if (xml.children.person.(@name=="Room").length()) trace('found Room wasn\'t there because the XMLList length is zero, Great! this is correct!')
    
    //now after I understand that, lets try the looping
    
    //get a person list from anywhere in the xml
    
    var myPeople:XMLList = xml..person;
    
    for each(var individual:XML in myPeople){
         var theseChildren:XMLList=individual.children.person;
         var numChild:uint = theseChildren.length()
         trace(individual.@name+" has children ?:"+Boolean(numChild))
         if (numChild) {
              trace ('the '+((numChild>1)? 'children are ':'child is '));
              for each(var directChild:XML in theseChildren) trace([email protected]())
         }
    }
    
  • ORA-19279 with several children in XML

    Hi all

    I get this error:

    ORA-19279: XQuery dynamic type mismatch: expected - singleton sequence got several sequence element

    When you try to select an XML type.

    The XML looks like:
    <users>
      <user>
        <username>123456</username>
        <details>
          <password>password</password>
          <forename>Barry</forename>
          <surname>Donovan</surname>
          <retired>0</retired>
          <email>email.com</email><phone>9999-88880333</phone>
        </details>
        <assignedRoles>
          <EXAM_CODE>9999_4949</EXAM_CODE>
          <EXAM_CODE>8888_3838</EXAM_CODE>
        </assignedRoles>
      </user>
    </users>
    My SQL to query it is:
    SELECT
           h.pin
          ,d.password
          ,d.forename
          ,d.surname
          ,d.email
          ,d.phone
          ,d2.exam_code
          FROM
             robin_temp x,
             xmltable('users/user' passing
                xml COLUMNS
                    pin       varchar2(1000) path 'username'
                  , lineitem  xmltype        path 'details'
                  , lineitem2 xmltype        path 'assignedRoles') h,
             XMLTable('details' PASSING
                h.lineitem COLUMNS
                   password varchar2(1000) path 'password'
                  ,forename varchar2(1000) path 'forename'
                  ,surname  varchar2(1000) path 'surname'
                  ,email    varchar2(1000) path 'email'
                  ,phone    varchar2(1000) path 'phone') d,
             xmltable('assignedRoles' passing
                  h.lineitem2 columns
                  exam_code varchar2(1000) path 'EXAM_CODE' d2                   
    Basically, because there is the child < details > and the < assignedRoles > child, I get this error. But I don't know what we can do about it...

    I'm still trying to sort this issue, but so far no joy at all... I can't imagine that it's a rare thing, then someone can help?

    Thank you so much in advance.

    Robin

    And multiple details, something like that...

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select xmltype('
      2    
      3      123456
      4      
    5 password 6 Barry 7 Donovan 8 0 9 email.com9999-88880333 10
    11 12 9999_4949 13 8888_3838 14 15
    16
    ') as xml from dual) 17 -- 18 -- end of test data 19 -- 20 select x.username 21 ,y.password 22 ,y.forename 23 ,y.surname 24 ,y.retired 25 ,y.email 26 ,z.exam_code 27 from t 28 ,xmltable('/users/user' 29 passing t.xml 30 columns username varchar2(20) path './username' 31 ,details xmltype path './details' 32 ,assignedroles xmltype path './assignedRoles' 33 ) x 34 ,xmltable('/details' 35 passing x.details 36 columns password varchar2(20) path './password' 37 ,forename varchar2(20) path './forename' 38 ,surname varchar2(20) path './surname' 39 ,retired number path './retired' 40 ,email varchar2(50) path './email' 41 ) y 42 ,xmltable('/assignedRoles/EXAM_CODE' 43 passing x.assignedroles 44 columns exam_code varchar2(20) path '.' 45* ) z SQL> / USERNAME PASSWORD FORENAME SURNAME RETIRED EMAIL EXAM_CODE -------------------- -------------------- -------------------- -------------------- ---------- -------------------------------------------------- -------------------- 123456 password Barry Donovan 0 email.com 9999_4949 123456 password Barry Donovan 0 email.com 8888_3838 SQL>
  • How to get specipic children length() in xml


    When Serching for levalid Sting. How can I get this leval page length;

    example 1: search string = "m0_l0_t1" the length of these swift page = 2

    Example 2: search string = "m0_l0" the length of these swift page = 3,

    var myxmlL:XML =

    < root >


    < levalid module = "m0" >

    < levalid lesson = "m0_l0" >
    < levalid topc = "m0_l0_t0" >
    < levalid pages = "m0_l0_t0_p0" >
    < page id = "1" / >


    < / pages >

    < / topc >

    < levalid topc = "m0_l0_t1" >
    < levalid pages = "m0_l0_t1_p0" >

    < page id = "1" / >
    < page id = "2" / >

    < / pages >
    < / topc >
    < / lesson >

    < / module >

    < root >

    Try this:

    myXML.pages. (@levalid.indexOf (stringToSearch) == 0).page.length)

  • Problem with accessing XML children

    Hi all
    I have a huge problem that has been bothering me for the past few hours... it drives me nuts in fact...
    below my code and a screenshot of what I mean exactly... I tried to keep it as short as possible

    Basically when I try to access a subnode (a.project.name in this example) XML, flex does not seem to do anything.
    as you can see b should be "Project1". Instead, it's only a variable initialized XMLList, nothing more...
    normally, everything works without problems... the only difference in my current situation to 'normally' which is the main XML where everything is derived is sitting in an external class.
    However, I can access it when filling a tree control for example so no problem there...
    problems begin when I try to 'dig deeper '...

    I know my way around e4x and may exclude any data type of problems etc...

    http://I32.Tinypic.com/eg8wtw.PNG

    I'm about to pull my hair! Please someone help me ^^ thanks in advance

    'a' is probably already in the 'project '.

    make: trace (a.toXMLString ()); to check

    I suspect you will want to just:
    var b:XMLList = b.SID;

    All the e4x expressions etourner an XMLList, it's just empty the apppropriate isn't fair.

    Tracy

  • Data from the XML file

    Hello

    The attached xml file contains data that I would like to extract. The value of the data has the label (ubchild? name /) of ' means ".". " This can happen a number of times in the file for the names of different children.  for example

    SENS0710:10951:IntSolIrr has the value that

    742.320755

    and

    SMBAU008:154000347:m_S0 kWh has the value that

    227.458679

    and so on...

    The attached vi is very very simple and uses the vi JKI EasyXML to parse the file to a data type of labview.

    This is the point at which I need advice as to the way forward. I have reflected on the variant data, clusters, etc., but can't seem to get anything close to work.

    Someone would be kind enough to give me some tips or tricks to extract these values in a table.

    Thankl you

    Concerning

    Ray

    Hi rayclout,

    I don't have parser Xml JKI vi... But I used the default XML functions and can read the average tag. Please find the screenshot of it.

    Thank you and best regards,

    srikrishnaNF

  • Help parsing XML (XMLParseDemo.java)

    Hello world

    I'm trying to parse the XML code in my application. Here's a sample of what I'm trying to analyze:

    
    
      http://api.netflix.com/catalog/titles/autocomplete?{-join|&|term}
      
        
      
      
        
      
      
        
      
      
        
      
    
    

    For the parser, I use the XMLDemoScreen.java that is provided in the JDE samples. What I'm trying to do is to analyze all of theitem. However, when I run the application, my output is as follows:<p class="help"> <pre> autocomplete url_template = <a href="http://api.netflix.com/catalog/titles/autocomplete?{-join" rel="external nofollow noreferrer">http://api.netflix.com/catalog/titles/autocomplete?{-join</a>|&|term}" autocomplete_item title autocomplete_item title autocomplete_item title autocomplete_item title </pre> <p class="help">So, that's the impression not the values of "title". Anyone know why? Is it because the element contains<title short="">?<p class="help"> <p class="help">Thanks for your help. Here is the code that I use (which can be found in the JDE samples):</p> <pre> /* * XMLDemoScreen.java * * Copyright © 1998-2009 Research In Motion Ltd. * * Note: For the sake of simplicity, this sample application may not leverage * resource bundles and resource strings. However, it is STRONGLY recommended * that application developers make use of the localization features available * within the BlackBerry development platform to ensure a seamless application * experience across a variety of languages and geographies. For more information * on localizing your application, please refer to the BlackBerry Java Development * Environment Development Guide associated with this release. */ package com.kflicks.xml; import java.io.InputStream; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.MainScreen; import net.rim.device.api.xml.parsers.*; import org.w3c.dom.*; /** * The main screen for the application. Displays the results of parsing the XML * file. */ /* package */public final class XMLDemoScreen extends MainScreen { // Constants // ----------------------------------------------------------------------------------- private static final int _tab = 4; InputStream input; /** * This constructor parses the XML file into a W3C DOM document, and * displays it on the screen. * * @see Document * @see DocumentBuilder * @see DocumentBuilderFactory */ public XMLDemoScreen(InputStream input) { setTitle(new LabelField("XML Demo")); this.input = input; try { // Build a document based on the XML file. DocumentBuilderFactory factory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(input); // Normalize the root element of the XML document. This ensures that // all Text // nodes under the root node are put into a "normal" form, which // means that // there are neither adjacent Text nodes nor empty Text nodes in the // document. // See Node.normalize(). Element rootElement = document.getDocumentElement(); rootElement.normalize(); // Display the root node and all its descendant nodes, which covers // the entire // document. displayNode(rootElement, 0); } catch (Exception e) { System.out.println(e.toString()); } } /** * Displays a node at a specified depth, as well as all its descendants. * * @param node * The node to display. * @param depth * The depth of this node in the document tree. */ private void displayNode(Node node, int depth) { // Because we can inspect the XML file, we know that it contains only // XML elements // and text, so this algorithm is written specifically to handle these // cases. // A real-world application will be more robust, and will handle all // node types. // See the entire list in org.w3c.dom.Node. // The XML file is laid out such that each Element node will either have // one Text // node child (e.g. <Element>Text</Element>), or >= 1 children // consisting of at // least one Element node, and possibly some Text nodes. Start by // figuring out // what kind of node we're dealing with. if (node.getNodeType() == Node.ELEMENT_NODE) { StringBuffer buffer = new StringBuffer(); indentStringBuffer(buffer, depth); NodeList childNodes = node.getChildNodes(); int numChildren = childNodes.getLength(); Node firstChild = childNodes.item(0); // If the node has only one child and that child is a Text node, // then it's of // the form <Element>Text</Element>, so print 'Element = "Text"'. if (numChildren == 1 && firstChild.getNodeType() == Node.TEXT_NODE) { buffer.append(node.getNodeName()).append(" = \"").append( firstChild.getNodeValue()).append('"'); add(new RichTextField(buffer.toString())); } else { // The node either has > 1 children, or it has at least one // Element node child. // Either way, its children have to be visited. Print the name // of the element // and recurse. buffer.append(node.getNodeName()); add(new RichTextField(buffer.toString())); // Recursively visit all this node's children. for (int i = 0; i < numChildren; ++i) { displayNode(childNodes.item(i), depth + 1); } } } else { // Node is not an Element node, so we know it is a Text node. Make // sure it is // not an "empty" Text node (normalize() doesn't consider a Text // node consisting // of only newlines and spaces to be "empty"). If it is not empty, // print it. String nodeValue = node.getNodeValue(); if (nodeValue.trim().length() != 0) { StringBuffer buffer = new StringBuffer(); indentStringBuffer(buffer, depth); buffer.append('"').append(nodeValue).append('"'); add(new RichTextField(buffer.toString())); } } } /** * Adds leading spaces to the provided string buffer according to the depth * of the node it represents. * * @param buffer * The string buffer to add leading spaces to. * @param depth * The depth of the node the string buffer represents. */ private static void indentStringBuffer(StringBuffer buffer, int depth) { int indent = depth * _tab; for (int i = 0; i < indent; ++i) { buffer.append(' '); } } } </pre> <p class="help">Thank you!</p> <p class="reply">You should get properly "title" attributes of node via</p> <p class="reply">NamedNodeMap attributes = node.getAttributes ();</p> <p class="reply">iterate through the mapping of attributes to retrieve the values you want.</p>

  • Read the nodes that have the same value as the subnodes - XML

    It is more of a general JAVA / XML problem, but given that it is going into my BlackBerry app I thought I'd see if anyone knows.

    Consider a simple XML document:

                        Whatever 1                   Whatever 2               Whatever 3       
    

    Using the standard org.w3c.dom, I can get the nodes in X by the practice...

    NodeList fullnodelist = doc.getElementsByTagName ("x");

    But if I want to go to the next set of 'e', I try to use something like...

    Element element = (Element) fullnodelist.item(0);NodeList nodes = pelement.getElementsByTagName("e");
    

    EXPECTED back '3' nodes (because there are 3 series of 'e'), but it returns '9' - because it gets all entries including the 'e' apperently.

    It would be nice in the above case, because I could probably go through and find what I'm looking for. The problem I have is that when the XML file looks like the following:

                whatever              Something Else                    whatever              Something Else            
    

    When I ask 'e' value, it returns 4, instead of (what I want) 2.

    I am simply not understand how DOM parsing works? Generally, in the past I used my own XML documents so I name never articles like this, but unfortunately this isn't my XML file and I don't have the choice to work like this.

    What I thought I would do, it is write a loop knots "drills down" so that I can combine each node...

      public static NodeList getNodeList(Element pelement, String find)
        {
            String[] nodesfind = Utilities.Split(find, "/");
            NodeList nodeList = null;
    
            for (int i = 0 ; i <= nodesfind.length - 1; i++ )
            {
                nodeList = pelement.getElementsByTagName( nodesfind[i] );
                pelement = (Element)nodeList.item(i);
            }
    
            // value of the nod we are looking for
            return nodeList;
        }
    

    .. While if adopted you ' s/e' in the service, he would return the 2 nodes I'm looking (or elements, perhaps I'm using the wrong terminology?). on the contrary, it returns all the 'e' nodes in this node.

    Anyway, if anyone is still with me and has a suggestion, it would be appreciated.

    Well, there is no doubt that there is a learning curve robust for XML programming. You can take an hour or two and go through one of the tutorials that are circulating on the net. (Like that of w3schools.com.)

    Basically, almost everything in XML is a node, the Document that returns the parser. The API for node tells you that you can test the node type you have by calling getNodeType, which returns one of the constants of type node (Node.ELEMENT_NODE, Node.TEXT_NODE, etc..) If necessary, you can then convert the variable to the corresponding interface (element, text, etc.).

    Similarly, the API documentation say you for any node, calling getChildNodes (or for an element node or Document getElementsByTagName) will give you a NodeList (a little non-types of nodes in the XML API), while calling getFirstChild and getNextSibling to any node will give you another node (or null ).

    Once you learn the API, writing logic of course is not all that hard. For example, if the only 'e' interest tags are those directly under the element root of the document (as shown in your example) you can simply go to them directly:

    Vector getTopENodes(Document doc) {  Vector vec = new Vector();  NodeList nodes = doc.getDocumentElement().getChildNodes();  int n = nodes.getLength();  for (int i = 0; i < n; ++i) {    Node node = nodes.item(i);    if (node.getNodeType() == Node.ELEMENT_NODE &&        "e".equals(node.getNodeName()))    {      vec.addElement(node);    }  }  return vec;}
    

    Note that this example does not assume that all children are nodes of element 'e '. the document could have comments, white space or something else that makes it into the DOM as comment, text or any other type of node.

    On the other hand, if you want to capture every "e" tag which is directly under the ' tag, no matter the level, then you need to do something a little more complicated (it's on the top of my head - no guarantee):

    static class NodeListImp implements NodeList {  private Vector nodes = new Vector();  public int getLength() {    return nodes.size();  }  public Node item(int index) {    return (Node) nodes.elementAt(index);  }  public add(Node node) {    nodes.addElement(node);  }}
    
    NodeList getTargetNodes(Document doc) {  NodeListImp list = new NodeListImp();  getTargetnodes(list, doc.getDocumentElement(), false);  return list;}
    
    void getTargetNodes(NodeListImp list, Node node, boolean parentIsS) {  if (node.getNodeType() == Node.ELEMENT_NODE) {    // node name is tag name for element nodes    String name = node.getNodeName();    if (parentIsS && "e".equals(name)) {      list.add(node);    }    parentIsS = "s".equals(name);    for (Node child = node.getFirstChild();         child != null;         child = child.getNextSibling())    {      getTargetNodes(list, child, parentIsS);    }  }}
    

    I hope that it gets the idea across.

  • Eception java.lang.error trying to create format XML string

    I am trying to create XML documents without having to build everything manually whenever I want to do this.  I created a XMLFile class to create the document.  When I try to launch my app TestFoo, I get untrapped Exception java.lang.error.  I tried kxml2, using org.w3c.dom, java XML, banging my head against the wall as to why it will not work until I finally just rolled my own simple implementation.  I always get the error!  No details are provided.  There is no stack trace.  I use the emulator 9000 "BOLD" crossing os 4.6.0 eclipse 3.4.1

    Console:

    Starting TestFooStarted TestFoo(154)Exit TestFoo(154)ErrorNo detail messageTestFoo Document  0x171TestFoo XMLFile  0x381TestFoo TestFoo  0x297TestFoo TestFoo main 0x276
    

    TestFoo.java

    import net.rim.device.api.system.Application;
    
    public class TestFoo extends Application {
    
      public static void main(String[] args) {      TestFoo foo = new TestFoo();      foo.enterEventDispatcher();   }
    
      public TestFoo() {        XMLFile xml = new XMLFile("rootNode");        xml.addProperty("myprop", "some value");      System.out.println(xml.toFormattedXMLString());       System.exit(0);   }}
    

    XMLFile.java

    public class XMLFile {   Document document;    public XMLFile(String rootElement) {      document = new Document(rootElement); }
    
      public void addProperty(String pName, String pText) {     Element elm = new Element("property");        elm.addAttribute("name", pName);      elm.setTextContent(pText);        document.appendChild(elm);    }    public String toFormattedXMLString() {     return document.toFormattedXML();    }}
    

    Element.Java

    import java.util.Enumeration;import java.util.Hashtable;import java.util.Vector;
    
    public class Element {   private Vector children;  private String name;  private String textContent;   private Hashtable attributes;
    
      public Element(String name) {     this.children = new Vector();     this.attributes = new Hashtable();        this.name = name; } public void appendChild(Element child) {      this.children.addElement(child);  } public Vector getChildren() {     return children;  } public String getName() {     return name;  } public void setName(String name) {        this.name = name; } public String getTextContent() {      return textContent;   } public void setTextContent(String textContent) {      this.textContent = textContent;   } public Hashtable getAttributes() {        return attributes;    } public boolean hasChildren() {        return (this.children.size() > 0); } public int childrenCount() {      return this.children.size();  } public String getAttributeValue(String name) {        return this.attributes.get(name).toString();  } public void addAttribute(String key, String value) {      this.attributes.put(key, value);  } public void addAttribute(String key, int value) {     addAttribute(key,Integer.toString(value));    } public void addAttribute(String key, long value) {        addAttribute(key,Long.toString(value));   } public void addAttribute(String key, boolean value) {     addAttribute(key, String.valueOf(value)); } public boolean hasAttribute(String name) {        return this.attributes.containsKey(name); } public Element getChild(int position) {       return (Element) this.children.elementAt(position);   } public Enumeration getAttributeKeys() {       return this.attributes.keys();    }}
    

    Document.Java

    import java.util.Enumeration;
    
    public class Document { private static final char _gt = '>';   private static final char _lt = '<';   private static final char _eq = '=';  private static final char _dqt = '"'; private static final char _cl = '/';  private static final char _sp = ' ';  private static final char _tab = '\t';    private static final byte[] _nl = System.getProperty("line.separator").getBytes();
    
      private Element rootNode; private StringBuffer sb;
    
      public Document(String rootName) {        this.rootNode = new Element(rootName);    } public void appendChild(Element child) {      this.rootNode.appendChild(child); } public String toFormattedXML() {      sb = new StringBuffer();      format(this.rootNode,0);      return sb.toString(); }
    
      private void format(Element node, int depth) {        writeOpenTag(node, depth);        for (int i=0;i0;i--) {            sb.append(_tab);      } }    private void writeOpenTag(Element node, int depth) {       indent(depth);        sb.append(_lt);       sb.append(node.getName());        for (Enumeration keys = node.getAttributeKeys();keys.hasMoreElements();) {            String key = keys.nextElement().toString();           sb.append(_sp).append(key);           sb.append(_eq).append(_dqt);          sb.append(node.getAttributeValue(key).toString());            sb.append(_dqt);      }    }    private void writeCloseTag(Element node, int depth) {       if (node.hasChildren()) {         sb.append(_lt).append(node.getName());        } else {          sb.append(_cl);       }     sb.append(_gt).append(_nl);    }}
    

    This line:

    private static final byte[] _nl = System.getProperty("line.separator").getBytes();
    

    is originally a NullPointerException because line.separator is not well supported. The line terminator standard for XML is CR/LF, so you can use:

    private static final byte[] _nl = { '\r', '\n' };
    

Maybe you are looking for

  • error "Invalid operation name failed" erase usb (tails.iso)

    Hello New user of the community, old mac user. Were trying to erase these two disks USB bootable "residue" I did and I get the same error listed above 'invalid name - operation failed' for both, tried in utility disk and with command terminal, termin

  • Bad Info de Support technique Apple?

    I want to transfer my data on a pc windows for my new Mac Air so I bought a USB 3.0 / ethernet adapter.  The tech support person told me it wouldn't work and that I would need a lightning / ether net adapter.  Is this correct?

  • What is the problem with my phone?

    Hello Just this afternoon, I started noticing that verification does not work for some things.  For example, I can not connect in my Apple ID on my iPhone.  It is said that "Audit Failed."  Also, when I enter almost all sites, it says that the server

  • Timing of a State Machine in the States

    Hi LabView community. I'm running a state machine (attached) in which I want to measure the duration that the VI is running in several States. The VI is used to take spectra of power of various samples. My scheduled execution goes like this: the user

  • How to extract data from cluster of component-level?

    I use the harmonic Analyzer function to read the cluster of component-level, which cotain for channel 0 and 1 data But having problem with playing on the basic component for each channel (part of the table 1). Pleas help. Thank you