0

Hi i am laoding a 3rd party xml file but its broken it has no root eliment and has no encoding at the start the xml file looks like the demo below

    <channel>
    <name>redbull ( amazing red bull plane )</name>
    <url>youtube.com/redbull<url>
    </channel>
    <channel>
    <name>redbull1 ( amazing red bull boat )</name>
    <url>youtube.com/redbull1<url>
    </channel>

How do i go about removing the () and all the text within it ?

i dont know regex but have been told this is the best way todo it if i dont want to take apart the html using dom

also how would i go once removed the brackets and text echoing out every name and url like belw

    name:url
    name:url

thanks a lot :)

1 Answer 1

1

you may try to use such regex

/<name>([^\(]+)\s.+<\/name>\s*<url>(.+)<url>/g

DEMO

There you find explanation of use regex elements

I hope you understand how use this regex in php code

Sign up to request clarification or add additional context in comments.

1 Comment

you are amazing i google regex search and replace and use this and its working perfect thanks you saved me hours of googling

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.