Pretty simple i’m sure, but..
I’ve got a file that is guaranteed to have only an <h1>some text</h1> and a <p>some more text</p> in it.
How would i go about returning these to elements as separate variables?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your file is just text, so you’re going to have to parse it. Generally HTML isn’t all that suitable for parsing with normal operations, but if you know the exact contents you shouldn’t have a problem.
Depending on what your separator is between the two tag blocks (let’s pretend it’s a
\n, you could do something like this:That would give you the two text blocks in
$h1and$p. You could parse the rest from there if you needed to do more work.