Ok, I have XML like this (XML Exhibit A) that I read in from a file
ala .. $doc->load("./Template.xml"); because I could not figure out
how to set the !DOCTYPE element.
------ XML Exhibit A-----
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE graph SYSTEM "graph.dtd" >
<graph/>
--------------
I would like to change <graph/> to be like <graph start="e-2h" end="N"
width="600" height="300"/> But when I try it (using Code Exhibit A) I
get "<graph/><graph start="e-2h" end="N" wi...."
------ Code Exhibit A ------
$doc = new DomDocument('1. 0','UTF-8');
$doc->load("./Template.xml");
// create root node
$graph = $doc->documentElemen t;
$graph->setAttribute(' start', 'e-2h');
$graph->setAttribute(' end', 'N');
$graph->setAttribute(' width', '600');
$graph->setAttribute(' height', '300');
$newNode = $doc->appendChild($g raph);
---------------------
So I guess in the end I have two questions.
#1 How do you set "<!DOCTYPE graph SYSTEM "graph.dtd" >"?
#2 How to you modify an existing node? 2 2744
John VanRyn wrote: #1 How do you set "<!DOCTYPE graph SYSTEM "graph.dtd" >"?
<?php
// Create an instance of the DomImplementati on class
$impl = new DomImplementati on;
// Create an instance of the DomDocumentType class by
// calling the DomImplementati on::createDocum entType() method
// (arguments: doctype_name, doctype_public, doctype_system)
$dtd = $impl->createDocument Type("graph", "", "graph.dtd" );
// Create an instance of the DomDocument class by
// calling the DomImplementati on::createDocum ent method
// (arguments: NS_URL, NS_PREFIX, DomDocumentType _instance)
$dom = $impl->createDocument ("", "", $dtd);
// Set other properties
$dom->encoding = "UTF-8";
$dom->standalone = "no";
// Create an empty element
$element = $dom->createElement( "graph");
// Append the element
$dom->appendChild($e lement);
// Retrieve and print the document
echo "<pre>", htmlentities($d om->saveXML()), "</pre>";
?>
#2 How to you modify an existing node?
This can be done with the replaceChild method:
// Get the node list
$nodelist = $dom->getElementsByT agName("graph") ;
// Get the node and copy it
$old_element = $nodelist->item(0);
$new_element = $old_element;
// Set the attribute for the new element
$new_element->setAttribute(" foo","bar");
// Replace it
$dom->replaceChild($ old_element, $new_element);
HTH;
JW
"Janwillem Borleffs" <jw@jwscripts.c om> wrote in message news:<41******* *************** @news.euronet.n l>... John VanRyn wrote: #1 How do you set "<!DOCTYPE graph SYSTEM "graph.dtd" >"?
<?php
// Create an instance of the DomImplementati on class $impl = new DomImplementati on;
// Create an instance of the DomDocumentType class by // calling the DomImplementati on::createDocum entType() method // (arguments: doctype_name, doctype_public, doctype_system)
Line 14:> $dtd = $impl->createDocument Type("graph", "", "graph.dtd" ); // Create an instance of the DomDocument class by // calling the DomImplementati on::createDocum ent method // (arguments: NS_URL, NS_PREFIX, DomDocumentType _instance) $dom = $impl->createDocument ("", "", $dtd);
// Set other properties $dom->encoding = "UTF-8"; $dom->standalone = "no";
// Create an empty element $element = $dom->createElement( "graph");
// Append the element $dom->appendChild($e lement);
// Retrieve and print the document echo "<pre>", htmlentities($d om->saveXML()), "</pre>";
?>
Warning: Couldn't fetch DOMDocumentType in
/var/www/html/TocGrapher/test7.php on line 14
Fatal error: Call to undefined method stdClass::creat eElement() in
/var/www/html/TocGrapher/test7.php on line 21
I tried looking up the solution, can't find it. could some one lend
some help please? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: softwareengineer2006 |
last post by:
All Interview Questions And Answers
10000 Interview Questions And Answers(C,C++,JAVA,DOTNET,Oracle,SAP)
I have listed over 10000 interview questions asked
in interview/placement test papers for all companies between year
2000-2005
in my website
http://www.geocities.com/allinterviewquestion/
So please have a look and make use of it.
|
by: connectrajesh |
last post by:
INTERVIEWINFO.NET
http://www.interviewinfo.net
FREE WEB SITE AND SERVICE FOR JOB SEEKERS /FRESH GRADUATES
NO ADVERTISEMENT
|
by: freepdfforjobs |
last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions
http://www.questpond.com/SampleInterviewQuestionBook.zip
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: Drew |
last post by:
I posted this to the asp.db group, but it doesn't look like there is much
activity on there, also I noticed that there are a bunch of posts on here
pertaining to database and asp. Sorry for cross-posting.
I am trying to build a "checklist", where a user can navigate to an ASP page
on the intranet which shows a list of "questions" that the user can check
off. I am trying to figure out how to do this so that it is scalable, but I
am...
|
by: Krypto |
last post by:
Hi,
I have used Python for a couple of projects last year and I found it
extremely useful. I could write two middle size projects in 2-3 months
(part time). Right now I am a bit rusty and trying to catch up again
with Python.
I am now appearing for Job Interviews these days and I am wondering if
anybody of you appeared for a Python Interview. Can you please share
the questions you were asked. That will be great help to me.
| |
by: ramu |
last post by:
C# Interview Questions and Answers8
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html
C# Interview Questions and Answers7
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html
C# Interview Questions and Answers 6
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html
C# Interview Questions and Answers 5...
|
by: ramu |
last post by:
C# Interview Questions and Answers8
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html
C# Interview Questions and Answers7
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html
C# Interview Questions and Answers 6
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html
C# Interview Questions and Answers 5...
|
by: ramu |
last post by:
C# Interview Questions and Answers8
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers8.html
C# Interview Questions and Answers7
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers7.html
C# Interview Questions and Answers 6
http://allinterviewsbooks.blogspot.com/2008/07/c-interview-questions-and-answers-6.html
C# Interview Questions and Answers 5...
|
by: reema |
last post by:
EJB Interview Questions
http://interviewdoor.com/technical/EJB-Interview-Questions.htm
CSS Interview Questions
http://interviewdoor.com/technical/CSS-Interview-Questions.htm
C Interview Questions
http://interviewdoor.com/technical/C-Interview-Questions.htm
C# Interview Questions
http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm
C++ Interview Questions
http://interviewdoor.com/technical/C++-Interview-Questions.htm
|
by: reema |
last post by:
EJB Interview Questions
http://interviewdoor.com/technical/EJB-Interview-Questions.htm
CSS Interview Questions
http://interviewdoor.com/technical/CSS-Interview-Questions.htm
C Interview Questions
http://interviewdoor.com/technical/C-Interview-Questions.htm
C# Interview Questions
http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm
C++ Interview Questions
http://interviewdoor.com/technical/C++-Interview-Questions.htm
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |