Forum Discussion

thebick's avatar
thebick
Occasional Contributor
4 years ago
Solved

getting XML DOM tagName fails

Microsoft XML DOM Properties page shows "tagName" as a property. But when I try to use it with

# Python
Log.Message("Node tag: " + mynode.tagName)

I get "AttributeError: The object does not support this property or method"

I can use "nodeName", "nodeValue", "xml", "text", or various other properties with no problem.

Indeed, the "xml" property shows the tag name and the value.

But how do I get just the tagName? Why doesn't it work, or why is it not supported?

  • Tried this:

    function testTagName() {
      let a = Sys.Browser('*').Page("https://community.smartbear.com/t5/TestComplete-General-Discussions/getting-XML-DOM-tagName-fails/m-p/199506").Panel(1).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0);
      Log.Message("TagName = ", a.tagName);
    }
    
    

    And it worked, give me DIV

     

    So by TC it's ok.

    Do you load an external XML ? with which method and which driver ?

     

3 Replies

  • BenoitB's avatar
    BenoitB
    Community Hero

    Tried this:

    function testTagName() {
      let a = Sys.Browser('*').Page("https://community.smartbear.com/t5/TestComplete-General-Discussions/getting-XML-DOM-tagName-fails/m-p/199506").Panel(1).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0);
      Log.Message("TagName = ", a.tagName);
    }
    
    

    And it worked, give me DIV

     

    So by TC it's ok.

    Do you load an external XML ? with which method and which driver ?

     

  • thebick's avatar
    thebick
    Occasional Contributor

    This finally worked for me:

    # this "mynode" is the parent of the node with the text value
    # 0 indicates an Element
    # This may need refining if the Element node has qualifiers within it
    if aqObject.GetVarType(myNode.nodeValue) == 0:
      tagName = aqConvert.VarToStr(myNode.nodeName)
      subNode = myNode.childNodes[0]
      myvalue = aqConvert.VarToStr(subMode.nodeValue)
      Log.Message("tagName " + tagName + " has value " + myvalue)