• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Does getNodeName() function exist?????

Hi, I 'm working with XML and XPATH

var nodes = xmlDoc.selectNodes( "//"+oNodeName );              
for(var i=0;i<nodes.length;i++)
{
alert("---> "  + nodes[i].getAttribute("ExternalKey")); // THIS FIRST STATEMENT GOES WELL
alert("---> "  + nodes[i].getNodeName());                 // THIS SECOND STATEMENT GOES BAD.....
}  

The message in browser is:
     <<<<<<< The object does not support this method >>>>>>>

1. I NEED TO GETTHE NODE CHILD NAME.
2. CAN I CREATE A NEW ATTRIBUTE TO THIS NODE CHILD? CAN YOU GIVE ME A SAMPLE?

Help me, please!!!!
0
jorgeani
Asked:
jorgeani
  • 3
  • 2
1 Solution
 
YZlatCommented:
you could try something like that:

if (node.HasChildNodes) {
 string childname = node.FirstChild.FirstChild.Name();
}
0
 
YZlatCommented:
sorry, my bad:

if (node.HasChildNodes) {
 string childname = node.FirstChild.Name();
}
0
 
jorgeaniAuthor Commented:
I´m using XPATH in Javascript
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
Carl TawnSystems and Integration DeveloperCommented:
Assuming this is javascript, try:

    alert("---> " + nodes[i].nodeName);
0
 
YZlatCommented:
if (node.HasChildNodes) {
 string childname = node.FirstChild.Name;
 child = node.FirstChild;
 XmlAttribute attr;
 attr = doc.CreateAttribute("test");
 attr.Value = "3";
 child.Attributes.Append(attr);
}
0
 
jorgeaniAuthor Commented:
THANKS!!!!!!!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now