XML Reader Examples

1. Element counting

Total no. of elements: #myXML.Count('//*')#

Total no. of projects with 10 or more downloads: #myXML.Count('//project[DOWNLOADS > 10]')#

2. Getting element names

Names of child elements in the 'project' element: #ArrayToList( myXML.Names('//project/*') )#

3. Searching the XML

a. Get the project names: #ArrayToList( myXML.Search('//project/NAME') )#

b. Get project names with links and output in a list:

  1. #proj[i].name#

End of XML Reader examples

// XML Editor examples, no output just code examples (can check the outputted files for results) // 1. Writing to file myXML.Write(ExpandPath('projects_start.xml')); // 2. Add author element to each project author = StructNew(); author.firstname = "Dominic"; author.lastname = "Watson"; nElementsCreated = myXML.CreateElement("//project", "author", author); // 3. Add id attribute to each project for(i=1; i LTE myXML.Count("/projects/project"); i=i+1){ myXML.CreateAttribute("/projects/project[#i#]", "id", i); } // 4. Update download count for project with id = 1 nElementsUpdated = myXML.Update("//project[@id=1]/DOWNLOADS", "234,337,12 and counting!"); // 5. Delete all comments (not that there are any, but I like this code) nElementsDeleted = myXML.Delete('//comment()'); // 6. Delete URL Name from all projects: nElementsDeleted = myXML.Delete('//project/URLNAME'); // 7. Write to new file to see the difference myXML.Write(ExpandPath('projects_end.xml'));