PHP

PHP – use a regular expression to extract a URL from XML attribute

I was working on an API response, which provided data in a custom XML markup within the string, which was returned. I wanted to simply extract the “linkTerm”. The snippet I got looked like this: <link linkTarget=”URL” linkTerm=”https://some.provider.com/lib/something/detail.action?docID=5176530″ linkWindow=”_blank”>Online-Zugang</link> Now surely there will be more elegant ways of doing it, but I felt that I […]

PHP – removing unwanted XML from string

Yesterday I was working on a small PHP script in which an API sends “xml” within the response. That XML is supposed to make handling the data easier, but to be fair I just didn’t need it. This is the snippet that the API returned <searchLink fieldCode=”AR” term=”%22Krugman%2C+Paul+R%2E%22″>Krugman, Paul R.</searchLink> At first I tried to […]

Scroll to top