Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xml-help

Status
Not open for further replies.

Ator

Programmer
Jan 23, 2006
26
SE
hi

Using parser, how can i deal with xml tags?
For example, having

<aaa>...</aaa>
<bbb>...</bbb>
<ccc>...</ccc>
<ddd>...</ddd>
<eee>...</eee>
<fff>...</fff>

and $currentTag = <aaa>
can i see the value of tag <fff>;
 
If you use the available XML-Parser and XML-DOM modules, you can read the entire document into a memory structure. Once read, you can access any subdivision (node) in the XML document. That having been said/typed, I find myself wandering away from using those modules. They work as advertised, but, if you are reading big XML files, then they used large amounts of memory and can be quite slow.

If your XML structure is fairly simple and consistent, I would use a little regex stuff to parse the file and build a memory structure of just those elements that I really need. This avoids a lot of overhead the modules bring and uses a minumum of memory.

Conversely, if your XML is complex and inconsistent, then, buy some more memory and use the modules.

just my $.02 'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top