General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Unsable to get value of node from node list

  • russurquhart1

    Unsable to get value of node from node list

    Participants 1
    Replies 0
    Last Activity 9 years ago

    Hi,

    I've used the getNodesByXPath to get nodes in the past, but in this case, where i want the text inside the node, i get either nothing (with .nodeValue) or undefined (with .data). The .nodeName produces the element name correctly. Here is the code i have:

    var objNode = ActiveDocument.documentElement;
    var nodelist = objNode.getNodesByXPath(“//PartNumber”);
    Application.Alert(nodelist.length + ” PartNumber elements in this doc.”);
    var nodecount = nodelist.length;
    var all_the_rows = “”;

    if (Selection.CanInsert(“SubSection”))
    {

    for (i=0; i {
    var current_PartNumber = nodelist.item(i);

            Application.Alert(“Node Name: ” + nodelist.item(i).nodeName);
            Application.Alert(“Node Value: ” + nodelist.item(i).nodeValue);
            Application.Alert(“Node Value: ” + nodelist.item(i).data);

    var current_PartNumber_Str = current_PartNumber.text;
    var all_the_rows = all_the_rows + row_str;

    }

    Can anyone provide some pointers to do this?

    Thanks,

    Russ

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support