Sample code for 30+ languages & platforms
PowerBuilder

XML GetChildWithAttr

See more XML Examples

Demonstrates how to get the content of a particular node with a particular attribute. For example, returns "Face up in the Rain" for the Name="Album" node.
 <Response Status="OK">
   <Item Name="ZoneID">0</Item>
   <Item Name="State">2</Item>
   <Item Name="FileKey">305718</Item>
   <Item Name="Artist">Michael Tomlinson</Item>
   <Item Name="Album">Face Up in the Rain</Item>
   <Item Name="Name">The Way We're Going</Item>
   <Item Name="Status">Playing</Item>
</Response> 

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Xml
oleobject loo_XItem

li_Success = 0

loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")
if li_rc < 0 then
    destroy loo_Xml
    MessageBox("Error","Connecting to COM object failed")
    return
end if

li_Success = loo_Xml.LoadXmlFile("qa_data/resp.xml")
if li_Success <> 1 then
    Write-Debug loo_Xml.LastErrorText
    destroy loo_Xml
    return
end if

loo_XItem = loo_Xml.GetChildWithAttr("Item","Name","Album")
if loo_Xml.LastMethodSuccess = 0 then
    Write-Debug "not found."
    destroy loo_Xml
    return
end if

Write-Debug loo_XItem.Content

destroy loo_XItem


destroy loo_Xml