473,385 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Regarding additions to XML via PHP

14
I'm developing a web app. Right now it's going by pretty easily. Unfortunately, I'm having trouble writing to an XML file and it's beginning to get hairy over here. So, my question is this: How can I take this code and make it add to my already started XML file?

Expand|Select|Wrap|Line Numbers
  1. $newNode = "<allusers></allusers>";
  2. $xmlRoot = simplexml_import_dom($xmlDoc);
  3. foreach ($parr as $nodes => $vals) {
  4.         $txt = "<" . $nodes . ">" . $vals . "</" . $nodes . ">\n";
  5. }
  6. $xmlRoot->addChild("<user>",$txt);
  7. echo $xmlRoot->asXML();
Apr 3 '16 #1

✓ answered by Dormilich

XML does not support innerHTML. so you have to add the tags one-by-one.
Expand|Select|Wrap|Line Numbers
  1. foreach ($parr as $nodes => $vals) {
  2.     $parentNode->addChild($nodes, $vals);
  3. }

2 1075
Dormilich
8,658 Expert Mod 8TB
XML does not support innerHTML. so you have to add the tags one-by-one.
Expand|Select|Wrap|Line Numbers
  1. foreach ($parr as $nodes => $vals) {
  2.     $parentNode->addChild($nodes, $vals);
  3. }
Apr 4 '16 #2
aunk
14
Yea I figured that out last night writing the code, aft I'd asked this question. Thanks!
Apr 4 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Dave Horoschak | last post by:
I am looking for some additions to a Perl-based auction script. I need to set up a system that allows buyers and sellers to e-mail each other without sharing their contact information. This will...
29
by: C A Upsdell | last post by:
Comments re these three related, proposed CSS 3 additions? 1. Add 'text-transform:time', which would transform text in the format hours:minutes:seconds (24 hour clock) to the local format for...
6
by: Cro | last post by:
Dear Access Developers, The 'Allow Additions' property of my form is causing unexpected results. I am developing a form that has its 'Default View' property set to 'Continuous Forms' and am...
10
by: Michel Rouzic | last post by:
I need to determine how long does an addition take and how long does a multiplication takes. So far I've been trying to use the clock() function in my programs in order to find out how long it took...
3
by: paquer | last post by:
I want users to be able to set the Allow Additions property to 'True' via a command button when required. (The command also adds data to the subform) If they skip the command, they skip the data...
3
by: mahaveer | last post by:
Hi , I am facing a strange problem with STL maps ,I am using gdb to debug my debug my code. Upto one point the number of entries in the map is shown as follows , $79 = {_M_t = { _M_impl...
8
by: BASSPU03 | last post by:
I'm using Access 2003 on a Windows XP O/S. I've made two copies of Form1 so that there're are 3 forms: 1) Form1 2) Form2 3) Form3 Essentially, they all write to the same Table1.
2
by: blakerrr | last post by:
Hi All, I have a subform, which needs to allow for additions. When I set the "Allow Additions" property to Yes, the form still doesn't allow me to add anything. Am I missing something...
6
by: Peng Yu | last post by:
Hi, ANSI and GNU C are different in some delicate aspects (I'm not sure about C++). For example, M_PI is not in ANSI C but in GNU C. Of course, to make my program most portable, I should go...
4
lifeisgreat20009
by: lifeisgreat20009 | last post by:
I have just started learning VC++ We have seen how to make a simple applications such as a dialog box or making split windows and displaying Hello World ! etc..... We have seen how MFC creates lot...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.