Editting XML Attributes With SimpleXML?
Ive been trying to figure out how to edit XML Node Attributes, Can someone point me in the right direction? ....
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Simplexml + Namespace +attributes
I have an XML file with some elements like those below <core:District Id="AB01"> <core:Name>NORTH EAST</core:Name> <core:Association Type="type1">VALUE 1a</core:Association> <core:Association Type="type2">VALUE 1b</core:Association> <core:Association Type="type3">VALUE 1c</core:Association> </core:District> <core:District Id="AB02"> <core:Name>NORTH WEST</core:Name> <core:Association Type="type1">VALUE 2a</core:Association> <core:Association Type="type2">VALUE 2b</core:Association> <core:Association Type="type3">VALUE 2c</core:Association> </core:District> I'm trying to parse it using simplexml I have: $districts = $xmlfile->children($core); foreach ($districts as $key => $value) { echo "Name = " . $value->Name . " "; echo "Region1 = " . $value->Association[0] . " "; echo "Region2 = " . $value->Association[1] . " "; echo "Region3 = " . $value->Association[2] . " "; } This works fine, but I am unable to access the Id attribute in the opening District element, i.e. AB01 or AB02. Would anyone be able to suggest how I might get that value with simplexml?
Simplexml And Attributes With A Namespace In Front. How Do You Getthe Attribute?
Here's a bit of xml code that works. <?php $string = "<?xml version="1.0" standalone="yes"?> <world> <people xmlns:ss="http://crap"> <person id="5">John Doe</person> <person id="2">Susie Q. Public</person> </people> </world>"; $xml = simplexml_load_string($string); print "<pre>"; print_r($xml); print "</pre>"; foreach($xml->people->person as $p) foreach($p->attributes() as $a =$b) { print "$a =$b<br />"; } // prints out // id =5 // id =2 ?> Now what if I change the first person to this <person ss:id="5">John Doe</person> Anyone know how to get the id? This is a question that is pertinent to an excel .xml file as you'll get lines like this <Cell ss:Index="3">stuff</Cell> btw: there is a guide on ibm that tells you how to do this with php and dom. I'm just wondering if there's a way to do it with simplexml.
Editting A Txt File On My Server...
I have a login form with username and password (html of course). When you hit submit, I want the php script i have to make a log of that login. Heres what I got for the html part: <form action="login.php" method="post"> Username: <input type="text" name="usr" /> Password: <input type="password" name="pass" /> <input type="submit" /> </form> I want the php's name to be login.php, and the text file's name is loginlog.txt.
Editting A .doc File On Linux
Is it possible to edit a .doc file on linux? I know about doing it on Windows using COM but thats not much use on linux.
SimpleXML
What, besides the new php 5.0 zip package, do I need to get SimpleXML to work on my testing server? The docs say to copy libxml2.dll to the system32 directory but I can't find this dll anywhere in the binary package (or anywhere else for that matter). I'm running IIS 6.0 fwiw.
Using SimpleXML
I have started using SimpleXML and can do most things, but there are a couple of things that I can't seem to figure out. Currently, I can: 1. Open & load an XML file 2. Manually parse the XML file 3. Search the XML file using XPath 4. Make changes to existing nodes (values) However, I can't seem to be able to: 1. Add a new node / element. 2. Save my changes back to the XML file Am I missing something, or are these things that currently cannot be done with SimpleXML?
Valid XML For SimpleXML
I'm trying to use SimpleXML but I've run into a conundrum. Every day an XML file is generated that this script grabs and manipulates. How can I check that the XML has no problems before creating my SimpleXMLelement object. Here's what I mean: // this is the code in question: $file_topstory = /some/xml/file.xml $top_story_xml = new SimpleXMLElement($file_topstory, NULL, TRUE); If the XML doc contains (for example) a URL with an '&' in it then the script fails. I'd like to do something like this: if(is_valid_xml($file_topstory)){ $top_story_xml = new SimpleXMLElement($file_topstory, NULL, TRUE); }else{ // ERROR }
How To Authenticate When Using SimpleXML
I've got an RSS feed I'd like to consume from our Sharepoint server. When I try: $xml = simplexml_load_file($url); I get failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized This is understandable as I need to specify a username and password to access the RSS. How can I do this with SimpleXML, or, should I first call the URL with cURL and work with the stream locally? I thought there may be some global params I could set for the stream handling library of PHP.
PHP5 Simplexml
I'm trying to output from an XML string and am having no luck. I'm using PHP5 here. If I print_r the array I get all the results plus extra text, but am unable to extract the individual response. Any pointers appreciated. Here's the code that shows the results... $get_all_value = $xmlrpc_resp->value(); $albums_array = php_xmlrpc_decode($get_all_value); print $albums_array['string']; Here's the result string that I want to break up ... xmlrpcval Object ( [me] => Array ( [string] => <photos page="1" pages="1" perpage="500" total="155"> <photo id="114766115" owner="xxxxxx" secret="xxxxxx" server="50" title="Water Pump, Bushy Park" ispublic="1" isfriend="0" isfamily="0" /> <photo id="114765757" owner="xxxxxx" secret="xxxxxx" server="36" title="Deer, Bushy Park" ispublic="1" isfriend="0" isfamily="0" /></photos> ) [mytype] => 1 [_php_class] => )Many thanks
SimpleXML Question
I'm running in to a little issue with SimpleXML, and wondered if anyone knew if it was normal implementation for SimpleXML, or I'm not using a correct flag, or even it's a an issue that should be resolved. I'm actually only just starting to use SimpleXML with any vigor, so I may well be mistaken about what I think it should do... Basically, if you take this simple chunk of XML:
Merging XML In PHP Using SimpleXML And DOM
I'm having trouble trying to merge two SimpleXML objects (user preference settings) in PHP. It should be simple enough - the objects have the same root element, and I simply want to merge at the top child level. However, the code I'm providing here, while it executes, does not work. At the end of the merge() function, the merged preferences are empty. Code:
Writing To XML Using Either DOM Or SimpleXML
I've been having quite some trouble figuring out specific XML coding in PHP5. I'm trying to edit and remove specific tags in a specific way using DOM (I'd rather use SimpleXML but it seems rather limited on this area). Code:
Parse Xml-rpc Using SimpleXML
I am trying to parse through a XML document...a XML-rpc response to be exact...the good thing is the code is doing as its told. Code:
SimpleXML Catching 404
I'm building a script with the last.fm datafeeds. When a incorrect username is given to the script, the last fm site throws a 404, and results in this PHP error: Warning: simplexml_load_file(http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/richardm/public_html/lastfmcompatibility.php on line 12 Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=" in /home/richardm/public_html/lastfmcompatibility.php on line 12 There was a problem loading the data feed. Is there a way to catch this error and just present a friendly error?
SimpleXML & Google Images
I'm writing a script that would (hopefully) search google images for whatever, and then return a list of URLs for the image. Right now I have: $dom = new DomDocument(); $url = "http://images.google.com/images?q=hello"; $dom->loadHTMLFile($url); $sxe = simplexml_import_dom($dom); foreach($sxe->xpath('//img') as $node) { echo $node->src; } What this is supposed to do (line by line): Make a new DomDocument Define $url load the HTML file from $url make a simpleXML object from the loaded DOM go through all the image tags (using a DomNodeList w/ xpath) and print out the src attribute of the node.
SimpleXML Parsing By Attribute Value
I have an existing XML data set and would like to parse it with PHP5 based on the value of an attribute (any attribute!). I don't want to convert all my data from an attribute-heavy structure to a more proper element-based structure if I don't have to because of the javascript I am using on the client side. Listed below is the XML structure and PHP code I have been testing. My existing data structure looks like this: <gallery> <photos> <photo path = "sunflower01.jpg" width = "500" height = "375" thumbpath = "sunflower01.jpg" thumbwidth = "125" thumbheight = "94"> </photo> </photos> </gallery> The script is here: <?php $xml = simplexml_load_file("pictures.xml"); $image = $xml->xpath("/gallery/photos/photo[@path='sunflower01.jpg']"); echo $image[0]->photo@thumbpath; ?>
How To Search Xml W/simplexml Using Xpath()
I've been lookin over some simplexml notes/docs and i havent really found a way to search and return results example: <?xml ...?> <products> <cat1> <item> <name>product 1</name> <color>blue</color> </item> </cat1> <cat2> <item> <name>product 2</name> <color>blue</color> </item> </cat2> </products> if the user searches "blue", then i should be able to step through and process the valid <item> structures... same for if they search for "product 1", then just process the one valid structure (including its category)...
Weird Chars When Parsing With SimpleXML
I'm using php-5.0.5-pl3; I've created a collector class which populates itself with DOM's nodes from every object which needs to output data. So, at the end of the process, the collector has every piece of the result in a XML document. After this, I need to process the XML document according to the user document request (HTML, XML, Excel, etc.); to accomplish this, I'm using a SimpleXML to parse every node and reinterpret it. I've successfully accomplish HTML transformation, but I've trouble with Excel because some numeric entities aren't translated properly. For example: Importación (Importación) is translated to Importación Acuática (Acuática) is translated to Acuática España (España) is translated to España .... and so on. Is there any function to translate properly the accuted vocals ?
LDAP Attributes
I've got a problem with Sun's iPlanet Directory Server 5.1. I'm writing applications in PHP, and so far it's all going well. However, there appear to be some attributes that I can't fetch - one of these is passwordexpirationtime. I can get the usual stuff like uid, cn etc. but this (and some other attributes) cannot be fetched. I've tried binding anonymously, and as the directory administrator - but I still get the same result. It appears that I am limited to the following :- uid givenname objectclass sn cn userpassword creatorsname modifiersname createtimestamp modifytimestamp mail telephonenumber employeetype dn Is there anything that anyone could suggest ? Any help would be much appreciated - I need to provide a facility to let my users know when their password is about to expire.
NuSOAP + Attributes?
I've never used SOAP before, so am more than a little foggy on it. Just doing a project where it's basically the only way, and due to limitations on the server, I have to use nuSOAP (unless there's a better option that runs as a class...). Anyway, I've got it talking to the server happily.. Just not passing attributes. This is what I need, in straight SOAP XML stuff... <platformCore:email>eblack@yahoo.com</platformCore:email> <platformCore:password>Cracker1</platformCore:password> <platformCore:account>111111</platformCore:account> <platformCore:role internalId="3"/> And as far as I can see nuSOAP is called by $foo->call('login',$array); or similar. This is working. The bit I'm having trouble with is setting the internalId attribute on the role. array( 'email'=>'eblack@yahoo.com', 'password'=>'Cracker1', 'account'=> ?', 'role'=> array('name'=>'role', 'value'=>'') //need to add the internalId attribute //'role internalID="14"' => '' // outputs XML like ); Something like that. I've tried so many things, and get various errors back.. basically no dice though. It's talking, but rejecting me if I don't have an internalID or something else isnt right in the SOAP XML. For reference the second option above (commented out one) outputs something like this in XML (I assume...) <platformCore:role internalId="14"></platformCore:role internalId="14"> And it falls over at the whitespace in the closing tag. The first option just achieves nothing....
Add Attributes Elements To An XML Tag?
Whats the PHP code to add an XML tag with an attribute element in my SOAP message body. With output formatted corresponding to the following example: <PRSADRVBL soortEntiteit="R"> ............<other xml>........... </PRSADRVBL>
Parsing XML Attributes
I am using the following code and want to retrieve an attributes value. I want to loop through the xml file and add the attribute values to an array. The line in question is marked with "<---?" below. I have included both the PHP and XML. ################################################## ############# <?php $headlines = array(); $urls = array(); $match = ""; function opening_element($parser, $element, $attributes) { global $match; if ($element == "HeadLine"){ $match = "headline"; } elseif ($element == "NewsItemRef"){ $match = "url"; } }.........
Read Xml Attributes
i am trying to read the xml tag attributes in php but quite not getting it. If anyone have previously done it could you please help me out. I am including the xml code with the post. Code:
My Sql Length Attributes.
why does the length attribute, to set the character length of what is added to a a mysql field, only seem to work on varchar and not text?
Combining Like Attributes
I've got a master inventory list that includes the Item Description, it's location, and quantity. If I have duck tape in 3 places it will show: Duck Tape - Office - 2 Duck Tape - Shop - 27 Duck Tape - Trailer - 1 Can I combine all the duck tapes (and there are other multiples in this list that would need to be combined as well) it so the master list says: Duck Tape - 30 Etc...
Using Class Attributes?
I just picked up PHP& MySQL Web Development by Luke Welling and Laura Thomson 3rd edition and am having problems with the examples they use under 'Using Class Attributes'. Specifically, they say that "If an attribute of your current class is called $attribute, you refer to it as $this->attribute ..." What I don't understand is, in some of the examples the attribute has the $ and some it doesn't. I'm assuming that there is a reason for this, and that it's not merely a typo.
Remove Duplicate Items From A Simplexml Object
$foos = simplexml_load_file("bar.xml"); Lets say bar.xml has 50 entries and lets say 25-50% of those are duplicates. How would I get rid of those. Here is how I'm using it foreach($foos as $foo){ echo $foo->entry;} I don't think that $foos or $foos->entry is an array so array_unique won't work.
Problems Using PEAR HTTP_Request In Combination With SimpleXML
I'm just beginning with PHP and I'm trying to figure out how to handle HTTP Requests/Response with web services such as eBay and PayPal. In my research I've come across HTTP_Request included with PEAR. I've gotted it installed and tested successfully with the following: <?php require_once "HTTP/Request.php"; $req =& new HTTP_Request("http://www.ebay.com/"); if (!PEAR::isError($req->sendRequest())) { echo $req->getResponseBody(); } ?> That displays ebay's web site when I load the page so it seems that PEAR is working correctly. I'm trying now to move on and do an actual call to their API. It's the easiest call you can make with their API and it simply returns the official eBay time. Here is what I've got: <?php require_once "HTTP/Request.php";?> <?php $eBayAPICallName = "GeteBayOfficialTime"; $APIURL = "https://api.ebay.com/ws/api.dll"; $DevID = "My_Dev_ID_Here"; $AppID = "My_App_ID_Here"; $Cert = "My_Cert_Here"; $AuthToken = "My_Auth_Token_Here"; //eBay GetOfficialTime request $requestXMLBody = "<?xml version=""1.0"" encoding=""utf-8""?>"; $requestXMLBody .= "<GeteBayOfficialTimeRequest xmlns=""urn:ebay:apis:eBLBaseComponents"">"; $requestXMLBody .= "<RequesterCredentials>"; $requestXMLBody .= "<eBayAuthToken>" . $AuthToken . "</eBayAuthToken>"; $requestXMLBody .= "</RequesterCredentials>"; $requestXMLBody .= "</GeteBayOfficialTimeRequest>"; $req =& new HTTP_Request(); $req -> setURL($APIURL); $req -> setMethod(HTTP_REQUEST_METHOD_POST); $req -> addPostData($requestXMLBody); $req -> addHeader("X-EBAY-API-COMPATIBILITY-LEVEL", "511"); $req -> addHeader("X-EBAY-API-SESSION-CERTIFICATE", $DevID . ";" . $AppID . ";" . $Cert); $req -> addHeader("X-EBAY-API-DEV-NAME", $DevID); $req -> addHeader("X-EBAY-API-APP-NAME", $AppID); $req -> addHeader("X-EBAY-API-CERT-NAME", $Cert); $req -> addHeader("X-EBAY-API-CALL-NAME", $eBayAPICallName); $req -> addHeader("X-EBAY-API-SITEID", "0"); $req -> addHeader("X-EBAY-API-DETAIL-LEVEL", "0"); $XMLResponse = simplexml_load_string($req -> sendRequest()); echo $XMLResponse -> asXML(); ?> The idea behind this (from what i can piece together from tutorials and everything I've been studying) is that it constructs the basic XML string to use and uses PEAR's HTTP_Request to send it off. I'm storing the response in $XMLResponse with the SimpleXML PHP function hoping I could display the XML response in the browser to ensure things are working....but they're not. When I run this page I get a blank white browser back. View source has nothing but the empty basic html tags. All of the headers I've added were taken from working ASP scripts so know those are good (unless I've just done something wrong with syntax there or something). I've tested the simplexml stuff successfully using basic XML files located on my disk so I thought I had that setup correctly too. Obviously something is wrong somewhere, though.
XML File, Character Entities And SimpleXML Parser
I have the following XML file: <?xml version=1.0'?> <!DOCTYPE names [ <!ENTITY eacute "(ampersand)#233;"> ]> <site> <section id='about' name='about'> </section> <section id='portfolio' name='portfolio'> </section> <section id='resume' name='résumé'> </section> </site> I parse it with simpleXML, but by the time "resume" (you know-- the kind with e-acute characters) gets to the browser, the entities get mangled. Note that I *am* using the proper "DOCTYPE names" directive at top of the XML file, and I am saving my files as UTF8. Also note that in the code above, I replaced the ampersand with the word "ampersand" so it wouldn't parse on this message board. I think I'm missing a part of the big picture here. Any ideas?
Special Characters In XML Files Parsed With SimpleXML
I got a problem; when using php4 parsing xml files i get special characters displayed good. When using the simpleXML class, the special characters stay. example: ’ shows as ’ insteeds of ' Does anyone know how to fix this?
Quotes Around HTML Attributes
If I am using echo to return some HTML how do I get quotes around the attributes? In ASP I would use a double quote i.e. response.write ("<h1 align=""center"") to give <h1 align="center"> but this doesn't work in PHP, I'm hoping someone can enlighten me!
Product Attributes Problem?
While trying to design a database for shopping cart i encountered few problems which i am mentioning here. I had hierarchical level of categories for products for which i designed table as:
PHP SOAP And Setting Attributes
Does anyone know if you can set attributes using PHP's built-in SOAP library? I know you can do it with PEAR::SOAP but cannot see a way to do it with the built-in one.
Objects As Object Attributes
I'm building a site where i'm trying to use the DOMApi supplied with PHP. The basic idea is to make all my bricks as small xml-nodes that can be apprehended by others. The problem is that i'm having problems with defining objects as attributes. I'm a bit rusty with the PHP-syntax so please bear over with me. class Treatmentlist extends DOMNode { private $pDomL; private $pParent; private $pInitialized; public function __construct($aParent) { $pParent = $aParent; $pDom = $aParent->ownerDocument; } .... some other methods ... } The problem is that when I refer to $pDom, it doesn't recognize it as an object of the type DOMDocument. What would solve my problem ?
Soapserver Reading Xml Attributes
I have a issue with the php5 soap extention, i did setup an soap server and it is recieving data but in the xml the other party used attributes. below a code snippet from the recieved call. I am talking about the "datumtijd" is datetime in dutch Code:
Can You ECHO Object Attributes?
I receive the error "Catchable fatal error: Object of class Car could not be converted to string" whenever I try to echo one of its attributes. For example: $car = new car(); echo $car->model; model is a public attribute so is this error normal? I'm trying to avoid writing a display function or passing the attribute's value to a local variable.
SimpleXML And Load Php File (Content-type: Text/xml)
I'm taking my first steps with xml and SimpleXML functions. xml.php (It could be made dynamically with a mysql result I post this snippet for example) PHP Code xml.php: <?php $xmlstr = "<?xml version="1.0" standalone="yes"?>"; $xmlstr .= "<movies> <movie>Behind the Parser</movie> </movies>"; header('Content-type: text/xml; charset=utf-8'); echo $xmlstr; ?> PHP Code loadXml.php: I've got this nasty error : Warning: xml.php:2: parser error : Start tag expected, '<' not found in c:xxxwwwxmlexamplemioplot.php on line 3 Warning: $xmlstr = ""; in c:xxxwwwxmlexampleloadXml.php on line 3 Warning: ^ in c:xxxwwwxmlexampleloadXml.php on line 3 bool(false) I've got the same error in my web site . xml.php is a valid xml file, isn't it ? Therefore I'm wondering why the snippet doesn't work ?
Warning: Simplexml_load_file() [function.simplexml-load-file]:
heres the errors: Warning: simplexml_load_file() [function.simplexml-load-file]: core/combat/magic/Spark.const.xml:4: parser error : Extra content at the end of the document in C:Program Filesxampphtdocswinterswordcorecombatcombat.class.php on line 481 Warning: simplexml_load_file() [function.simplexml-load-file]: <mastery>Death</mastery> in C:Program Filesxampphtdocswinterswordcorecombatcombat.class.php on line 481 Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in C:Program Filesxampphtdocswinterswordcorecombatcombat.class.php on line 481 and heres the .xml document: Code:
[SimpleXML] Assigning Values To Elements Found With XPath
I want to find all elements named "field" in an XML doc and assign a new value to each one. I'd tried something like this: foreach ($xml->xpath('//field') as &$field) $field = $value; But that doesn't work, because (I think) XPath returns a temporary array, not a reference to an actual element. ("PHP Fatal error: Cannot create references to elements of a temporary array expression") Is there a way to assign values to elements located with XPath, or do I just have to iterate over the whole document?
Removing Attributes From Html Tags
I want to build a class which will return a stripped version of variable containing HTML tags. In my constructor i will use strip_tags to get rid of the unwanted tags in the variable. After that i'll call a method cleanup() which has to do the hard work. Lets say i fill an array with values containing attributes like Onclick Onmouseover Style in my constuctor. I will allow de <a> tag to be used, but i want to strip the tag from attributes mentioned above.
Need Access To Default File Attributes
When I was first learning php, I created an upload script. The basics of the script had: <form method="POST" ENCTYPE="multipart/form-data"> <input type="file" name="FILE"> <input type="submit" name="SUBMIT" value="Upload"> </form> Then in the submit section, it accesses the filename and filesize by virtue of a default php ability to extract these attributes by using: $FILE_name and $FILE_size (where _name gives the name of $FILE and _size gives the size of $FILE). if($SUBMIT) echo " Filename: $FILE_name <br> Filesize: $FILE_size"; Also, I did add the necessary lines to handle the post variables, like so: $FILE = $_POST['FILE']; $SUBMIT = $_POST['SUBMIT']; I have tried to mimic this script in a new upload script, but am unable to access those same attributes (_name and _size). At the time of my original upload script, we were running it on a Linux server (but I don't remember what we were running for a php version). Currently, I am running PHP 4.2.3 on Mac OS 10.2.8 server. One thought I had was that maybe PHP 4.2.3 no longer supports _name and _size. Or, maybe I am not handling the retrieval of the POST var for the file correctly? I wonder this because I did try print_r($_POST) and I only got the submit returned as a post var.
Strip Html Tags ATTRIBUTES With Reg Exp
I want to strip html attribute within a tag. e.g.: <td class="blah" colspan="2" bgcolor="#ffffff">blah</td> And I want to leave the 'colspan="2"' intact. result after stripping with reg exp: <td colspan="2">blah</td>
Regex: Want To Eliminate The Excess Attributes
In netscape bookmark files, there are lots of lines like this: <DT><A HREF="http://www.commondreams.org/" ADD_DATE="1091500674" LAST_CHARSET="ISO-8859-1" ID="rdf:#$uiYyb3">Common Dreams</A> I want to eliminate the excess attributes and values to get this: <DT><A HREF="http://www.commondreams.org/">Common Dreams</A> I almost succeed with this: $lines[]=preg_replace("{(<A HREF=".*")( ADD.*)(>.*</A>)}","13", $line); The only problem is the explicit "ADD". The code only works is there is an ADD_DATE attribute immediately after the url. I tried replacing ( ADD.*) with ( .*), which I thought would match everything up to the ">": $lines[]=preg_replace("{(<A HREF=".*")( .*)(>.*</A>)}","13", $line); For some reason, this does not find a match. Since " ADD" is the same as ..*, I don't understand why I need the explicit " ADD".
DomDocument: Setting Attributes To A New Node
I'm trying to create a single function to append new nodes to a DOMDocument object: public function addElement( $element, $name, $value = '', $attrs = Null ) { if( !( $created = $this->createElement( $name, $value ) ) ) throw new Exception( 'Could not create a new node ' ); if( !( $child = $element->appendChild( $child ) ) ) throw new Exception( 'Could not append a new node ' ); // Process and attachs the new attributes from array $attrs if any... // if( $attrs ) // foreach( $attrs as $attribute => $value ) // ... } So far, so good. Now I want to set attributes and its values of the recent created node (playing with createAttribute() and setAttribute(), but I can't get the DOMElement from the new child DOMNode. Is it possible without issuing getElementsByTagName() or getElementById() ?? Is another easy way -using DomDocument object- to create a new element (such <table width="50%" border="0">...</table>) which has its attributes and its values ?
Creating CSR With Multiple Values For Attributes
I'm trying to get PHP to generate a CSR in which I need the organizationalUnitName attribute/field to have multiple values. In the openssl.cnf file when generating the CSR with the "openssl req" command line, all I need is to include stanza such as: 0.organizationalUnitName = Level 0 OU 1.organizationalUnitName = Level 1 OU .... n.organizationalUnitName = Level N OU I hoped that for PHP, I just needed to build an array looking like dn_array = array( "0.organizationalUnitName" ="Level 0 OU" "1.organizationalUnitName" ="Level 1 OU" .... ); But what I get in the PHP errorlog at the openssl_csr_new($dn_array, ....) call is a: "dn: 0.organizationalUnitName is not a recognized name" message and so on for every multi-valued attribute... Any one ever succedeed in getting openssl_csr_new to do that stuff ?
DOM : Special Chars (entities) In Attributes
I currently use the DOM from PHP5 to create XHTML documents. I have a problem with entities. I would like to create a node: <input id="place" value="café rouge"> To do that I simply create the node with createElement, and then: $node -> setAttribute ("value", $val); If I set $val = "café rouge", the saveXML causes PHP to fail with an error message. The accentuated character seems to be a problem. If I set $val = "café rouge", saveXML automatically replaces the & with & and that's not what I expect either.
How To Parse-print Attributes From XML Document
I have a working XML parser and now want to print some of the attributes, I want to pull into an array the type and qualifier" attributes from "Screening": <Screening type="developer" qualifier="home"> the how can I do that ? Here is a piece of my XML doc: <Screenings> <Screening type="developer" qualifier="home"> <ScreeningResults type="result" mediaType="structured" resultType="report"> <Status>YES RECORD</Status> <Region>NC</Region> <County>UNION</County> Here is a piece of my parser: ............
How To Replace Special HTML Tags With Attributes
I'm working with XML and sometimes it's necessary to use temporary tags, that should be replaced before showing the source. How can I delete these tags? I assume, that I require preg_replace, but I don't know how to do it. Let's say I want to replace the <iteration ... > and the </iteration> tag from the following HTML code: PHP Code:
|