Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
How to Travese a xml string

Posted by vmk271 (vmk271), 8 April 2005
I need to find the node attributes(e.g permission in this case ) in the xml string. the sample string will look like this

XMl string
-------------

<corp>
  <report permission="10">
   <abstract permission="4"/>
   <transfer permission="10"/>
   <summary permission="5"/>
   <billing permission="10"/>
   <annuity permission="0"/>
  </report>
</corp>

how can i write a php function , the argument to the function will be the xpath(e.g corp/billing/@permission) and the output will be the permission value(e.g 10). Is there is any inbuilt function in php?



Posted by admin (Graham Ellis), 9 April 2005
If you're familiar with Xpath, have a look at the php.Xpath package on Sourceforge at http://sourceforge.net/projects/phpxpath/. The documentation is at http://www.carrubbers.org/scripts/php/xpath/doc/.  Not used it myself, but it looks like it might be the sort of thing you're looking for.  There's a quick start guide to using Xpath in PHP with this package at http://jm3.net/misc/php-xpath-quickstart/ - examples of the sort of thing you're looking for in just half a dozen lines of code.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho