XML parsing

I am trying to delete “node” along with its children from an xml file.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?> 
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/WaypointExtension/v1" xmlns:gpxtrx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" creator="Oregon 550t" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">
<metadata>
 <link href="http://www.abc.com">
  <text>abcl</text> 
  </link>
  <time>xyz</time> 
  </metadata>
  <trk>
  <name>sfa</name> 
<node>
 <a>
  <gb>Black</gb> 
  </a>
........
 </node>

The node is not deleted because of these long attribute values

<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/WaypointExtension/v1" xmlns:gpxtrx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" creator="Oregon 550t" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/WaypointExtension/v1 http://www8.garmin.com/xmlschemas/WaypointExtensionv1.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">

How can I skip these while parsing?

These “long attribute values” as you call them are actually namespaces and have absolutely nothing to do with any problems you may have with deleting a node.

Just tell us what node you want to delete and maybe someone can help you here (maybe even me but I’m not here all the time)

I want to delete

<node>
<a>
<gb>Black</gb>
</a>
</node>

but I found that if there are namespaces, the deletion doesn’t occur and if I remove namespaces, it does. I don’t know why? But I will need namespaces along with deletion of node

What PHP code are you using at the moment to (fail to) delete the element? With SimpleXML, you can generally unset() the chosen element. With DOM, you can call removeChild() on the parent element.