Page 1 of 1

How GetXMLAttribute() work ?

Posted: Sat Jun 02, 2007 9:27 pm
by Comtois
SetXMLAttribute() work fine, so what i am doing wrong with GetXMLAttribute() ? it dont work.

file : plan.xml

Code: Select all

<mesh>
    <submeshes>
        <submesh material="plan/system" usesharedvertices="false" use32bitindexes="false" operationtype="triangle_list">
            <faces count="2">
                <face v1="2" v2="1" v3="0" />
                <face v1="0" v2="3" v3="2" />
            </faces>
            <geometry vertexcount="4">
                <vertexbuffer positions="true" normals="true" texture_coord_dimensions_0="2" texture_coords="1">
                    <vertex>
                        <position x="0" y="0" z="0" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="-2" v="-2" />
                    </vertex>
                    <vertex>
                        <position x="1" y="0" z="0" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="2" v="-2" />
                    </vertex>
                    <vertex>
                        <position x="1" y="0" z="1" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="2" v="2" />
                    </vertex>
                    <vertex>
                        <position x="0" y="0" z="1" />
                        <normal x="0" y="1" z="0" />
                        <texcoord u="-2" v="2" />
                    </vertex>
                </vertexbuffer>
            </geometry>
        </submesh>
    </submeshes>
</mesh>

Code: Select all

file$ = "plan.xml"

Procedure AddNode(*Node, Position)
  name$ = GetXMLNodeName(*Node)
  AddGadgetItem (0, -1, name$, 0, position) 
  If name$ = "face"
    SetXMLAttribute(*Node,"v1","1234")
    ;ExamineXMLAttributes(*Node)
    ;While NextXMLAttribute(*Node)
      Debug GetXMLAttribute(*Node, "v1")
      Debug GetXMLAttribute(*Node, "v2")
      Debug GetXMLAttribute(*Node, "v3")
    ;Wend  
    Debug "----"
  EndIf  
  For child = 1 To XMLChildCount(*Node)
    *child = ChildXMLNode(*Node, child)
    AddNode(*child, position+1)
  Next  
EndProcedure

OpenWindow(0, 0, 0, 355, 280, "TreeGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
TreeGadget(0, 10, 10, 260, 260)                                         
tree = LoadXML(#PB_Any, file$)
status = XMLStatus(tree)
If status=0
  AddNode(MainXMLNode(tree), 0)
EndIf
SaveXML(tree,"test.xml")

Repeat

Until WaitWindowEvent() = #PB_Event_CloseWindow

Posted: Sat Jun 02, 2007 9:56 pm
by netmaestro
Well, as far as I can see what you have there should work. ExamineXMLAttributes() is succeeding, so the node type is correct, SetXMLAttribute() is returning non-zero, and while no return value is documented for this command, it would seem to indicate success. My skill with this new library is as limited as your own, but imho you haven't made any errors.

Posted: Sat Jun 02, 2007 11:48 pm
by akj
After extensive testing, I am convinced there is a bug in GetXMLAttribute()

In the meantime, as a workaround, write a procedure:

Code: Select all

Procedure.s GetXMLAttrib(*Node, name$)
If XMLNodeType(*Node)=#PB_XML_Normal
  ExamineXMLAttributes(*node)
  While NextXMLAttribute(*node)
    If XMLAttributeName(*node)=name$
      ProcedureReturn XMLAttributeValue(*node)
    EndIf
  Wend
EndIf
EndProcedure
Then call it like this:

Code: Select all

    Debug GetXMLAttrib(*Node, "v1")
    Debug GetXMLAttrib(*Node, "v2")
    Debug GetXMLAttrib(*Node, "v3")

Posted: Sun Jun 03, 2007 6:35 am
by Comtois
ok thank you , i post a bug report.

Posted: Wed Jun 13, 2007 1:21 pm
by netmaestro
Seems working perfect now under 4.10 B2 :D