E4X: Select the nodes that match a criterion, and whose children match to another

Hi guys,.

I'm writing a query of E4X to select the nodes that match a criterion, and whose children match to another. My actual dataset is a little more complex than this example, but this one is easy to follow.

Say that you are modeling a hierarchy of nodes, where each node can have zero or more parents and children. The XML file is a simple index of nodes, and each node contains their immediate parent and child relationships. In this way, you can start with a given node and build a tree in a direction any to any depth. As an extra flavor and selection criteria, each node has one or more colors that are associated with.

Here's a sample:

nodes <>

< node id = ' a' >

< name color = "red" / >

< child id = 'b' / >

< / node >

< node id = "b" >

< name color = "red" / >

< name of color = "green" / >

< parent = 'a' / >

< child id = "d" / >

< / node >

< = 'c' node id >

< name color = "blue" / >

< name of color = "green" / >

< child id = "d" / >

< / node >

< node id = "d" >

< name of color = "green" / >

< id parent = 'b' / >

< id parent = 'c' / >

< / node >

...

< / node >

Now, say I want to select all nodes root (those who have no parent relationships) that are red. This is the best I could come up with:

var nodeChildren:XMLList = nodeData.node. (! hasOwnProperty ('parent'))... Color. (@name == "red");
for each {(var childData:XML in nodeChildren)
var childID:String = nodeData.parent () .@id;

}

}

The first line gets us 90% of the way by selecting all of the nodes of color matching, but we have all these entries to get the id of the node that contains.

It is possible to select the nodes in one of the E4X without needing the loop?

Thank you!

Scott

So how about this?

nodeData.node. (! hasOwnProperty ('parent') & color.) (@name=="red").length () > 0)

Tags: Adobe Animate

Similar Questions

  • IS THERE A LIST OF THE DRIVERS THAT MATCH A FAILURE CODE? FOR EXAMPLE (0XDEEDFADE)

    IS THERE A LIST OF THE DRIVERS THAT MATCH A FAILURE CODE?  FOR EXAMPLE (0XDEEDFADE).  «I GET THIS WHEN I TRY TO CONNECT A RECORDER APPLICATION MY PC (WITH CODE SCREEN BLUE DEATH "DRIVER IRQL-NOT-DONOR-BASED EQUALITY).»

    [Moved from comments]

    There is no error like code: 0XDEEDFADE

    Usually due to a bad driver, or a faulty or incompatible hardware or software. Use the general troubleshooting of STOP the Messages above checklist. Technically, this error condition means that a kernel-mode process or driver tried to access a memory location to which it did not have permission, or at a kernel interrupt request level (IRQL) that was too high. (A kernel-mode process can access only other processes that have an IRQL lower or equal to, its own.)

    Make sure you uninstall and reinstall the drivers using the following general method.

    First of all, download the latest driver. Then perform the following steps.

    Click on Start Menu

    Right click on my computer/my computer

    Click on manage the

    Click Device Manager in the list on the left

    Find the device you are trying to uninstall by expanding the game appropriate device (network adapter/IDE ATA / ATAPI controllers)

    Right click on the device

    Click on uninstall (do not click OK in the dialog box that opens after hitting uninstall it)

    Put a check mark to remove software driver for this device (if this option is available, if not, just hit OK) and click OK

    Restart your computer only if Windows asks you to.

    Install the latest driver for the device.

    You can also:

    Sign in as an administrative user.

    First of all, download the latest driver. Then perform the following steps.

    Click on Start Menu

    Click on Control Panel

    Click on hardware and sound

    Click device (the last link under devices and printers) Manager

    Find the device you are trying to uninstall by expanding the game appropriate device (network adapter/IDE ATA / ATAPI controllers)

    Right click on the device

    Click on uninstall (do not click OK in the dialog box that opens after hitting uninstall it)

    Put a check mark to remove software driver for this device (if this option is available, if not, just hit OK) and click OK

    Restart your computer only if Windows asks you to.

    Install the latest driver for the device.

    My system specs

    System manufacturer/model number HP Pavilion e9110t

    Windows 7 Home Premium 64 Bit operating system

    Processor Intel (r) Core (TM) 2 CPU Quad Q9550 @ 2.83 GHz

    Card mother Pegatron IPIEL-A3

    6,00 GB Hundai HMT125U6BFR8C-H9 memory

    Graphics card ATI Radeon HD 4850

    Its Realtek High Definition Audio card / ATI High Definition Audio

    Monitor (s) displays Acer AL2216W

    Screen resolution 1680 x 1050

    Keyboard HP keyboard

    Mouse HP mouse

    Unknown/installed by HP POWER supply

    Generic HP case

    Cooling Stock Intel cooling

    Hitachi HDP725050GLA360 ATA Device 500 GB hard drives

    Internet download speed: 19.15 Mbps Upload: 1.67 Mbps

    Another news network adapter D Realtek RTL8168D/8111 Family PCI - E Gigabit Ethernet NIC (NDIS 6.20) network adapter 802.11n Wireless PCI Express Card LAN Adapter

  • Product that works well to choose Select the pages to an existing PDF and copy to a new PDF file?

    Product that works well to choose Select the pages to an existing PDF and copy to a new PDF file?

    Hi Gregh65396892,

    You must use Acrobat, you can download a free trial of 30 days from the following link: https://www.acrobat.com/en_us/free-trial-download.html

    After downloading and installing Acrobat, you can open both files in acrobat with enabled page thumbnails view, select the pages in a PDF document, then drag them to the pane "thumbnail" file pdf of another, and these pages will be copied in the second file.

    Kind regards
    Rahul

  • How can I make an osteonecrosis affects the form that will be present and send the pdf as an email?

    How to make a button on the form that will be present and send the pdf as an email?

    You can set up a button with an action to "Submit a form" and use a URL of the type mailto to specify the email address, you have the forms sent. If you want to send the whole PDF, select this option and not FDF or anything else. The mailto URL must not include spaces and the part "mailto" must be lowercase, as:

    mailto:[email protected]
    

    It will try to open an e-mail by using the users default email client. If the user has not implemented a or there is another problem, the email could not get started. If she has to work with versions of reader before 11, the form must be activated for the reader, what you do in Acrobat 11 selecting: file > save as other > Reader Extended PDF > activate tools more

  • I want to change the name that appears under 'To' and the 'author '.

    I want to change the name that appears under 'To' and the 'author '.

    No matter what particular place, or simply everywhere where you happen to be at this time?

  • OK to delete the files that are: C:/Documents and Settings/rjhirsch (me) / Local Settings/Application Data / identities / {31391EF3-B3AC-4F12-94D8-DC2DA45E9526} / Microsoft/Outlook Express

    Good afternoon:

    Have recently been spotted by Windows XP Pro disk space on my C drive is low.  I reinstalled all the obvious large files (e.g., photos) on an external hard drive.  I have drilled down into individual files on the C drive to ensure other potential consumers of space. Found the folder that can be the source.

    Last year, I converted from Outlook Express (OE) for Outlook.  At this point, I rode on my e-mail and the e-mail folders in Outlook.

    I found a file in the following location that seems to contain the OE files.  I would like to know if the removal of these files of OE (~8.5 GB) impact my Outlook folder/mail e-mail before I remove them.

    The location is: C:/Documents and Settings/rjhirsch (me) / Local Settings/Application Data / identities / {31391EF3-B3AC-4F12-94D8-DC2DA45E9526} / Microsoft/Outlook Express.

    The folder contains about 8.5 GB of e-mail to OE folders more of them are dated July/August 2010.

    It is safe to assume that when I converted originally these OE e-mail/folders over to Outlook - that Outlook has caught up - and it's OK to delete these files?

    Thanks for your help.

    Cheers.

    Rick

    If you do not use OE, then Yes. It will not affect Outlook at all. Open the database messages OE, the folder that you have described, and remove all the dbx files. If you need OE once again, when you open OE, it creates new files dbx for all default folders such as Inbox, sent, etc. items.

  • I have an active instagram account but I can't access despite the fact that my user name and password are correct.

    * Original title: INSTAGRAM BETA

    I have an active instagram account but I can't access despite the fact that my user name and password are correct.

    How can I fix?

    Help, please.

    You will need to contact Instagram.  We have no knowledge of their systems

  • What determines the order that CSS styles class and/or target rule are listed in the menu of the class of the HTML or CSS property inspector in Dreamweaver CC?

    Using Mac OS 10.10.4 and Dreamweaver 8 and Dreamweaver CC 2015 or Mac OS 10.6.8

    What determines the order that CSS styles class and/or target rule are listed in the menu of the class of the HTML or CSS property inspector in Dreamweaver CC?

    Is it possible to change the order in the drop-down list so that a frequently used class style/Targeted rule is listed first (to the top of the list)?

    I just have an attached style sheet and which shows alphabetically in the drop-down list. Maybe, if you have more than one style sheet, the styles appear in the load order of the leaves and alphabetically within each worksheet.

  • How to reset the function that allows tracks audio and video to align with the other tracks on the timeline

    Somehow, I have disabled the feature that allows to drag and draw audio and video tracks on the timeline to other titles or positions of import.  Is the only project that was hit, and everything that I can think is that when executing some other keyboard shortcuts, I accidentally performed a shortcut that turned this feature off.

    You want to say, "Snap"? Press "on the keyboard, or press the snap button in the timeline panel.

  • How can I download Creative Suite 5.5 that I bought before and it now takes on another computer?

    How can I download Creative Suite 5.5 that I bought before and it now takes on another computer?

    Follow this link to download & install:

    https://helpx.Adobe.com/Creative-Suite/KB/CS5-5-product-downloads.html

    Concerning

    Stéphane

  • Return all column names of the cells that match a value in a single cell

    I want to be able to scan all the cells in column 1 in column 3 (there could be several) which belong to the same line and check if they all have a value y (X). If they have no value, I want all columns to display all the names of the matching columns as follows: "column 1, column 2" for Elemento.

    This can be a good start:

    B2 = if (counta (C2) > 0, C$ 1, "" ") & IF (COUNTA (D2) > 0', ' & D$ 1," ") & IF (COUNTA (E2) > 0', ' & E$ 1," "") & IF (COUNTA (F2) > 0', '& F$ 1,' ')

    It's shorthand dethrone select cell C2, then type (or copy and paste it here) the formula:

    = IF (counta (C2) > 0, C$ 1, "" ") & IF (COUNTA (D2) > 0', ' & D$ 1," ") & IF (COUNTA (E2) > 0', ' & E$ 1," "") & IF (COUNTA (F2) > 0', '& F$ 1,' ')

    Select cell B2, copy

    Select the cells B2 the bottom of column D, dough

    To add additional columns, you copy the atomic unit:

    & IF (COUNTA (D2) > 0', '& D$ 1,' ')

    and update D2 with the new column and D$ 1 with the new column.

    then... If you add a new column (G, for example) that you want to change it:

    and IF (COUNTA (D2) > 0', '&D$1,' ')

    TO

    and IF (COUNTA (G2) > 0', "&G$1," ")

    and the updated formula would be:

    = IF (counta (C2) > 0, C$ 1, "" ") & IF (COUNTA (D2) > 0', ' & D$ 1," ") & IF (COUNTA (E2) > 0', ' & E$ 1," "") & IF (COUNTA (F2) > 0', ' & F$ 1,"") & IF (COUNTA (G2) > 0', '& G$ 1,' ')

    fill down like before

  • Select the node in af:treeTable

    Hello! My task is to change custom selection works on af:table and make it work for treeTable. Do the current method, I took this tutorial http://www.oracle.com/technetwork/developer-tools/adf/learnmore/25-generic-tree-selection-listener-169164.pdf

    And here's a method I have to change:

    public void TblStagesOnSelect (SelectionEvent selectionEvent) {}
    GeneralFunction.makeCurrent (selectionEvent);
    If (treeTable.getRowAtRangeIndex (treeTable.getCurrentRowIndex ()). GetAttribute ("IdParentStage") == null) {}
    parentUser.setAttributeValue (tf_idUserRespRequest.getValue ());
    } else {}
    for (int i = 0; i < = treeTable.getEstimatedRowCount () - 1; i ++) {}

    If (treeTable.getRowAtRangeIndex (treeTable.getCurrentRowIndex ()).getAttribute("IdParentStage").equals (treeTable.getRowAtRangeIndex (i) .getAttribute ("IdStage")))

    {

    parentUser.setAttributeValue (treeTable.getRowAtRangeIndex (i) .getAttribute ("IdUserResp"));
    break;
    }}}}

    This method has been written to the table, but it does not work on treeTable. Can anyone help?

    did you check that

    JDeveloper, Oracle ADF & amp; Java: Tree Table component in Oracle ADF (hierarchical representation)

    http://www.Oracle.com/technetwork/developer-tools/ADF/learnmore/26-get-selected-tree-node-data-169165.PDF

  • 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.

  • How to force the Explorer search to show ONLY the files that match the search target?

    I frequently need to search for files with brackets in the name of the file.    However, a bug in the Search Explorer means that search results will fill up with a lot of waste that does not match my search target.

    Example:

    At a command prompt "dir/s * (abc) *.» ' * ' usually works: the name of each file found will contain "(abc)".   (The only time that a search for the command line fails is when the version 8.3 of the name of the file matches the search target, but the name of the actual file does not work.)

    However, in Solution Explorer, look for "* (abc) *.» "*" returns all files with 'abc' in the name, and provides no way to filter the results so that I only see files with '(abc)' in the name of the file.

    This search bug means that you want "* (de) *.» ' * ' at the command prompt returns 72 hits, while searching with Explorer returns 7381 hits!

    Cancellation: Another inconvenience of Windows is when I work at a command prompt I get often unexpected results because the wildcard matching is done against both the full name of the file or folder and the name of 8.3.   Is there a way to force cmd.exe to restrict the wildcard matches only the complete names of the files and folders?  That is to say, is there a way to force cmd.exe to never, ever, use the 8.3 names?

    Hi Rob,

    In order to quickly provide a solution, please answer this question:

    Did you do changes on the computer before the show?

    Follow the steps below to solve the problem:

    Method 1: If you have problems of location of the files, folders, or other items on your computer, try using the search and indexing of troubleshooting to solve the problem. It ensures that the Windows Search service is running and checks if you have the correct permissions to search all the directories on your computer.

    See the article below for additional information and steps.

    Open the troubleshooter for search and indexing

    http://Windows.Microsoft.com/en-us/Windows7/open-the-search-and-indexing-Troubleshooter

     

    Method 2: I also suggest you to re - index files, then check. Follow the article below for the procedure.

    Change advanced indexing options

     http://Windows.Microsoft.com/en-us/Windows7/change-advanced-indexing-options

    See also:

    Improve Windows searches using the index: frequently asked questions

    http://Windows.Microsoft.com/en-us/Windows7/improve-Windows-searches-using-the-index-frequently-asked-questions

    Hope this information helps. Pleave get back if you need help, will be happy to help you.

  • How to select a picture, ignore one and many with shift click to choose several without also selecting the image that you have ignored.

    In the grid discovers how to select an image, a jump and select several images following the a l ignored without also selecting the previous image, that you have ignored as well. This is possible in opening

    Probably easier to select all the with shift-click and then deselect (ctrl-click), one that you don't want.

Maybe you are looking for