0

I am using code to get values of HTML attributes like:

Set myPhoto = doc.DocumentElement.getElementsByTagName("ul"):      i = 2
For Each e In myPhoto
    ...
    MyNodeValue = Trim(e.ChildNodes(0).ChildNodes(0).ChildNodes(0).src)
    ...
next

It has been working well until now. Excel shows me "Automation error" in case nodespath is exist.

The code string work well if use Children(0) vs Childnodes(0) like:

MyNodeValue =  Trim(e.Children(0).Children(0).Children(0).src)

I can't understand what happened with code and why ChildNodes(0) doesn't work?

braX
  • 11,506
  • 5
  • 20
  • 33
  • Note that there is a [edit] button to fix your question. • Probably it stopped working because your source HTML document structure changed? • Also please clarify in your tags if it is [tag:VBA] or [tag:VBScript]. These are 2 completely different languages. – Pᴇʜ Oct 18 '18 at 06:50
  • Hello Pᴇʜ. I have clarified tags. About HTML structure - that isn't change. I make an example in debbuger to show this case: http://prntscr.com/l7ehpt Please, check it. – Евгений Oct 18 '18 at 06:57
  • Possible duplicate of [What is the difference between children and childNodes in JavaScript?](https://stackoverflow.com/questions/7935689/what-is-the-difference-between-children-and-childnodes-in-javascript) – Pᴇʜ Oct 18 '18 at 07:06
  • It is not the same. The code like "...Childnodes(0)" works well, but it isn't work for now. The question is "Why it make an error now". Probably Microsoft does some updates this time (It is just guess about reason). I don't know, but I can't use many scripts becouse of it. My be someone know way to solve it. – Евгений Oct 18 '18 at 07:15
  • 1
    Where is the html and an explanation of what you are after please? Use the snippet tool to insert the html, not an image, so we can use for testing. Provide an URL of possible. At present this is off topic as when you ask why this code isn't working we should be able to reproduce the problem. – QHarr Oct 18 '18 at 10:06
  • And this is not an efficient method for retrieval so it would be worth updating your scripts to utilize better retrieval methods. – QHarr Oct 18 '18 at 10:53
  • Hello. I use script to get string data from HTML. It is not new script. I use it for couple of mounth. It had worked well untill now. It makes an error in accessing to childnodes. if I repleace Childnodes(item number) to Children(item number) - everething is OK, I try to understand why I can't get access to Childnodes as Childnodes(item number). http://prntscr.com/l7het2 it's make an error http://prntscr.com/l7hfm8. I don't know how you be able to reproduce the problem. – Евгений Oct 18 '18 at 10:56
  • QHarr - thanks for reply, Can you explane in more detail about "better efficient method", please. – Евгений Oct 18 '18 at 10:58

0 Answers0