0

What is difference between getElementsByTagName() with tagName and with .//tagName ?

When we pass tagname in the getElementsByTagName(), in that what is the meaning when we add ".//" ?

What is the difference between

sSourceInputXml->

getElementsByTagName(_bstr_t(".//author"), &xml2);

and

sSourceInputXml->

getElementsByTagName(_bstr_t("author"), &xml2);

?

Both return me same number of elements.

Any help is appreciated.

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
Veeru
  • 19
  • 4

1 Answers1

0

// means location step descendant-or-self:node(), which retrieves the current node and all its descendants.

. means self::node() which gets the context node.

Default location step is child, which gets the child elements of the context node.

If you need more information, check here.

EvgeniyZh
  • 898
  • 9
  • 21
  • Thanks for the info. But is there a difference if i use .//TagName and directly use TagName? ie. directly use author as shown: getElementsByTagName(_bstr_t("author"), &xml2); – Veeru Aug 27 '15 at 11:16
  • @Veeru as far as I understand, no. Default mode returns children of context, and .// returns context nose and its children. So unless you are searching for context node itself (sounds unlikely) there will be no difference. – EvgeniyZh Aug 27 '15 at 11:24
  • Thank you very much for a prompt response. – Veeru Aug 27 '15 at 11:35