Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2009
    Thanked 0 Times in 0 Posts

    XML Child Tag rename


    i have done many different way to rename Child TAG to allow

    here is example

         <author> dunno</author>

    i know it sound wrong code but i have different many way

    $dita = new DOMDocument;
    seems code is not working and i have try another way but fail

    my aim is change on outputclass XML like

    <?xml version="1.0"?>
         <child outputclass="internal" >bar</child>
         <price outputclass="internal >20</price>
         <author outputclass= "external"> dunno</author>
    that i want to set the outputclass attribute to outputclass="external" or "internal"

    or prefer use

    PHP (or XML) code call the "control file (can be an ASCII text file or an XML file)" , and then the PHP code does the processing logic on the desired DITA files based on the info in the control file.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,662 Times in 2,631 Posts
    You're usage of replacechild is incorrect. ReplaceChild requires two parameters, the new and the old nodes.
    However, I don't see where you're actually needing to do this. The difference between the two blocks of xml code only indicate changes in attributes. You can fetch a domNodeList from the getElementsByTagName method (it won't work on book though, since you don't have a book element), iterate through the list or fetch a single item (I assume that $id is for this purpose, but I don't see it defined anywhere), and use the createAttribute method on DomDocument, and append this to the desired DOMNode(s).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts