Tuesday, 27 April 2021

Parse the XML and update anchor tags?

   <description>
    <div class="field field-name-field-image field-type-image field-label- 
    hidden"><div class="field- items"><div class="field-item even"><a 
    href="/news/news/vg"><img 
    typeof="foaf:Image" src=""  width="220" height="147" alt="Police car- 
    sign" /></a></div></div></div><div class="field field- 
    name-body field-type-text-with-summary field-label-hidden"><div 
    class="field-items"><div 
    class="field-item even" property="content:encoded"><p> SOME TEXT </p> 
    </div></div></div>
 </description>

I am reading XML and parsing it wants to update all anchor tags in that XML: In the above eg, I want to append the domain name in a tag. If href attribute does not start with HTTPS or HTTP or www. I want to append the base URL to the href attribute.

How do I parse this HTML and search for anchor tag update it and return that Updated HTML?



from Parse the XML and update anchor tags?

No comments:

Post a Comment