How GetXMLAttribute() work ?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

How GetXMLAttribute() work ?

Post 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
Please correct my english
http://purebasic.developpez.com/
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post 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.
BERESHEIT
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Post 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")
Anthony Jordan
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

ok thank you , i post a bug report.
Please correct my english
http://purebasic.developpez.com/
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Seems working perfect now under 4.10 B2 :D
BERESHEIT
Post Reply