0

I am having a xml content like

<?xml version="1.0"?>     
              <content
                  ID="immunSect"/>
                  <table
                     border="1"
                     width="100%">
                     <thead>
                        <tr>
                           <th>Vaccine</th>
                           <th>Date</th>
                           <th>Status</th>
                        </tr>
                     </thead>
                     <tbody>
                        <tr>
                           <td><content
                              ID="immun2"/>Influenza virus vaccine</td>
                           <td>May 2012</td>
                           <td>Completed</td>
                        </tr>
                        <tr>
                           <td><content
                              ID="immun4"/>Tetanus and diphtheria toxoids</td>
                           <td>April 2012</td>
                           <td>Completed</td>
                        </tr>
                     </tbody>
                  </table>
               </text>

My problem is I would like to change this node

<tbody>
                        <tr>
                           <td><content
                              ID="immun2"/>Influenza virus vaccine</td>

into

<tbody>
                            <tr>
                               <td><content
                                  ID="immun2">Influenza virus vaccine</content</td>

Please help me how can I fetch that particular section and change the node structure from

<td><content id="xxx"/>test

into

<td><content id="xxx">test</content>
user2439124
  • 291
  • 1
  • 3
  • 16
  • 1
    It's difficult to tell what structure your XML has as the nodes in your post are either incomplete or malformatted – Maximilian Feb 04 '19 at 12:03
  • may help: https://stackoverflow.com/questions/4748014/updating-xml-node-with-php – Riad Feb 04 '19 at 12:15
  • 1
    Please go through some of your questions and mark them as resolved if appropriate - https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – Nigel Ren Feb 04 '19 at 12:34

1 Answers1

0

Basically when geting XML data, put loop until EOF in which get each line (@string1) and parse it, rewriting it to new variable (@string2), which you can save it to XML file/whatever you need with it. Start parsing @string1, moving everything to @string2, until you encounter and ignore it, instead put a flag to 1. Continue with copying, until you find then input into @string2 . Of course it can be done in more elegant way, but I would need to know what are you using to get XML data.

Hope that helps.