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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with string extraction

Status
Not open for further replies.

chomp99

IS-IT--Management
Apr 18, 2003
9
0
0
US
I spent too many hours on google trying to find the answer, can someone help? I would like to extract information that is nested between two strings (which are actually xml tags).

Example:
-some XML code is defined in a variable as text:
"<xml>
<title>Title here</title>
</xml>"

-I want to extract the data from that variable such that I am taking out the data nested in the tag: <title>Title here</title>

How can I search the variable and only keep the data between <title> and </title>? Or assign that data to a new variable?

Please ask if you don't understand what I'm asking.

Thanks in advance for your help!
 
I'm pretty sure the strip_tags() function works with <xml> tags.

*cLFlaVA
----------------------------
A polar bear walks into a bar and says, "Can I have a ... beer?"
The bartender asks, "What's with the big pause?
 
I did a small test with and without the <xml> tag and didnt seem to work. If it did work, it would be a great start but I still would need to get a more exact extraction.

What I'm trying to do is create a dynamic table that creates a row and uses the xml code from one cell in my database and shows the data from specific tags in the different <td> cells.

The same variable would be output to each <td> tag but a different extraction would occur in each <td> section. In the first <td> tag I would display the data in <title></title> from the xml, in the 2nd <name></name> etc....

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top