[solved] Parsing an HTML file with PHP XML functions
Posted: Thu Dec 14, 2006 3:37 am
Can some one tell me how to get started with parsing an HTML document using one of the PHP XML functions, i.e. which of the many PHP XML facilities can I use and how do I use it?
I have a file containing an HTML List that contains sublists, and I was wondering whether I could parse it like an XML file (which I'm sure you can) so I can determine the relationships between the lists.
For example if I know what the content is of one of the <li> tags in the nested list, I want to work out what the content of the parent <li> tag was that contains the <ul> nested list.
I'm not too hot on navigating through XML at the moment so this is really just an experimental exercise to form a breadcrumb from a hardcoded CSS menu. Usually these menus are formed from a database so I can use the database to generate the breadcrumb, but I thought I'd take a chance to learn something new, and I'm not saying its the best way of doing things.
I'm searching for tutorials and articles as we speak, but some starter code or if you point me to the relevant functions on PHP.net that would be helpful. There seems to be a lot of choice in the manual and I don't know where to start!
I have a file containing an HTML List that contains sublists, and I was wondering whether I could parse it like an XML file (which I'm sure you can) so I can determine the relationships between the lists.
For example if I know what the content is of one of the <li> tags in the nested list, I want to work out what the content of the parent <li> tag was that contains the <ul> nested list.
I'm not too hot on navigating through XML at the moment so this is really just an experimental exercise to form a breadcrumb from a hardcoded CSS menu. Usually these menus are formed from a database so I can use the database to generate the breadcrumb, but I thought I'd take a chance to learn something new, and I'm not saying its the best way of doing things.
I'm searching for tutorials and articles as we speak, but some starter code or if you point me to the relevant functions on PHP.net that would be helpful. There seems to be a lot of choice in the manual and I don't know where to start!