Loading ...
Sorry, an error occurred while loading the content.

Re: [phpXperts] How to change the attribute value of svg file [1 Attachment]

Expand Messages
  • rafiq sohel
    Got it. Here is the link if someone needs same solution: How to change the attribute value of a node in svg (or xml) file by php -rafiq7s
    Message 1 of 4 , May 18, 2010
    • 0 Attachment
      Got it.
      Here is the link if someone needs same solution:
      How to change the attribute value of a node in svg (or xml) file by php

      -rafiq7s


      From: rafiq sohel <rafiq7s@...>
      To: phpexperts@yahoogroups.com
      Sent: Mon, May 17, 2010 5:57:04 PM
      Subject: [phpXperts] How to change the attribute value of svg file [1 Attachment]

       

      Hello,

      In samplexml.svg there is a node <image width="744" height="1052" xlink:href=" image1.png" />
      I need to replace "image1.png" with another value like "image2.png" .
      Please guide me with sample code how to to that.

      I could get the attribute value "image1.png" . Here is the code:

      <?php
      $xdoc = new DomDocument;
      $xdoc->Load('samplexml. svg');
      $tagName = $xdoc->getElementsByTagNam e('image' )->item(0);
      $attribNode = $tagName->getAttributeNode( 'xlink:href' );

      echo "Attribute Name : ".$attribNode->name;
      echo "<br />Attribute Value : ".$attribNode->value;
      ?>

      Please help me, how to change this attribute value.

      Regards,
      rafiq7s


    • Abu Saleh Muhammad Shaon
      hi, you can try this way. $xdoc = new DomDocument; $xdoc- Load( test.svg ); $xdoc- getElementsByTagName( image )- item(0)- setAttribute(
      Message 2 of 4 , May 19, 2010
      • 0 Attachment
        hi,

        you can try this way.

        $xdoc = new DomDocument;
        $xdoc->Load('test.svg');
        $xdoc->getElementsByTagName('image' )->item(0)->setAttribute('
        xlink:href',"image2.png");
        echo $xdoc->saveXML();



         
        shaon
        Bengal Solutions Ltd
        http:asmshaon.wordpress.com



        From: rafiq sohel <rafiq7s@...>
        To: phpexperts@yahoogroups.com
        Sent: Mon, May 17, 2010 5:57:04 PM
        Subject: [phpXperts] How to change the attribute value of svg file [1 Attachment]

         

        Hello,

        In samplexml.svg there is a node <image width="744" height="1052" xlink:href=" image1.png" />
        I need to replace "image1.png" with another value like "image2.png" .
        Please guide me with sample code how to to that.

        I could get the attribute value "image1.png" . Here is the code:

        <?php
        $xdoc = new DomDocument;
        $xdoc->Load('samplexml. svg');
        $tagName = $xdoc->getElementsByTagNam e('image' )->item(0);
        $attribNode = $tagName->getAttributeNode( 'xlink:href' );

        echo "Attribute Name : ".$attribNode->name;
        echo "<br />Attribute Value : ".$attribNode->value;
        ?>

        Please help me, how to change this attribute value.

        Regards,
        rafiq7s


      • rafiq sohel
        Thanks! I am using setAttributeNS() instead of setAttribute(). Regards, rafiq7s ________________________________ From: Abu Saleh Muhammad Shaon
        Message 3 of 4 , May 19, 2010
        • 0 Attachment
          Thanks!
          I am using setAttributeNS() instead of setAttribute().

          Regards,
          rafiq7s



          From: Abu Saleh Muhammad Shaon <srabon_iiuc@...>
          To: phpexperts@yahoogroups.com
          Sent: Wed, May 19, 2010 7:25:27 PM
          Subject: Re: [phpXperts] How to change the attribute value of svg file

           

          hi,

          you can try this way.

          $xdoc = new DomDocument;
          $xdoc->Load('test.svg' );
          $xdoc->getElementsByTagNam e('image' )->item(0)->setAttribute( '
          xlink:href',"image2. png");
          echo $xdoc->saveXML();



           
          shaon
          Bengal Solutions Ltd
          http:asmshaon. wordpress. com



          From: rafiq sohel <rafiq7s@yahoo. com>
          To: phpexperts@yahoogro ups.com
          Sent: Mon, May 17, 2010 5:57:04 PM
          Subject: [phpXperts] How to change the attribute value of svg file [1 Attachment]

           

          Hello,

          In samplexml.svg there is a node <image width="744" height="1052" xlink:href=" image1.png" />
          I need to replace "image1.png" with another value like "image2.png" .
          Please guide me with sample code how to to that.

          I could get the attribute value "image1.png" . Here is the code:

          <?php
          $xdoc = new DomDocument;
          $xdoc->Load('samplexml. svg');
          $tagName = $xdoc->getElementsByTagNam e('image' )->item(0);
          $attribNode = $tagName->getAttributeNode( 'xlink:href' );

          echo "Attribute Name : ".$attribNode->name;
          echo "<br />Attribute Value : ".$attribNode->value;
          ?>

          Please help me, how to change this attribute value.

          Regards,
          rafiq7s



        Your message has been successfully submitted and would be delivered to recipients shortly.