473,509 Members | 3,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help required for remove_child function

62 New Member
Hello everyone.
I'm new to PHP and I'm trying to get some XML manipulation working. Somehow I can't get the remove_child method to work for me. Here are the details:

XML structure:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <?xml-stylesheet type='text/xsl' href='myXSL.xsl'?>
  3. <ServerList>
  4.     <Server id="myServer1">
  5.         <!--Some tags here. These tags have no children-->
  6.         <Tag1>AAA1</Tag1>
  7.         <Tag2>BBB2</Tag2>
  8.         <TagN>ZZZ3</TagN>
  9.     </Server>
  10.     <Server id="myServer2">
  11.         <!--Some tags here. These tags have no children-->
  12.         <Tag1>AAA4</Tag1>
  13.         <Tag2>BBB5</Tag2>
  14.         <TagN>ZZZ6</TagN>
  15.     </Server>
  16. </ServerList>
  17.  
I'm trying to capture some _REQUEST variables and create a new server node in the XML DOM. Before this, I query the DOM using xpath and the server id. If the server is found, I intend to delete that node and rest of the php code (creation of the new server node) follows suitably.

PHP code excerpt:
Expand|Select|Wrap|Line Numbers
  1. $dom=new DOMDocument();
  2. $dom->load("myXML.xml");
  3. $myXpath=new Domxpath($dom);
  4. //$ServerID is populated correctly based on _REQUEST variables.
  5. $myQuery="/ServerList/Server[@id='".$ServerID."']";
  6. $result=$myXpath->query($myQuery);
  7. if (($result->length) == 1) {
  8.     //What follows is line # L
  9.     $dom->document_element->remove_child($result->item(0));
  10. }
  11. //Some more code...probably irrelevant at this moment.
  12.  
The error I'm observing is:
Expand|Select|Wrap|Line Numbers
  1. Fatal error:  Call to a member function remove_child() on a non-object in myPHP.php on line L.
  2.  
I'm sure there is something wrong in my php code. Can someone kindly take a look and help me out ?
Thank you in advance,
Parag P. Doke
Apr 13 '08 #1
1 1075
paragpdoke
62 New Member
The page at:
http://www.php.net/manual/en/function.domdocument-document-element.php
has a comment saying "documentElement" should be used in PHP 5 rather than "document_element". With that change, I'm running into a new error with PHP 5.2.5.

How to use the remove_child method if it belongs to a DOMNode and not a DOMElement ? Or rather, how to convert output of DOMDocument->documentElement to type DOMNode so that the remove_child method is supported ?

Thanks in advance again,
Parag P. Doke
Apr 13 '08 #2

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

Similar topics

0
2786
by: mcp6453 | last post by:
I am trying to use Jack's FormMail script (http://www.dtheatre.com/scripts/formmail). Since I'm brand new at PHP and not very good at HTML, I have an easy question, which I will narrow down. When...
4
1988
by: Mike | last post by:
Please help this is driving me nuts. I have 2 forms, 1 user class and I am trying to implement a singleton class. Form 1 should create a user object and populate some properties in user. Form2...
3
4720
by: Webdiyer | last post by:
I want to integrate SecurID two-factor authentication system of the RSASecurity.inc into our asp.net application,but I get into trouble when trying to call the API functions of the ACE Agent,I got...
2
5026
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
1
1950
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
5
3713
by: Dennis Fazekas | last post by:
Greetings, I am creating a web form which will all the user to add an unlimited number of email addresses. Basically I have 3 buttons, "Add Another Email", "-" to remove, and a "Save" button....
36
3068
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it...
0
5519
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
2184
by: Milagro | last post by:
Hello Everyone, I'm trying to debug someone elses php code. I'm actually a Perl programmer, with OO experience, but not in php. The code is supposed to upload a photo from a form and save it...
0
7237
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
7137
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
7347
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,...
1
7073
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5062
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4732
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.