Jump to content

Z33M@N

Members
  • Posts

    31
  • Joined

  • Last visited

    Never

Everything posted by Z33M@N

  1. Hi guys, I have the following code here <form action=""> <input type="text" name="text" value="the text here"/> <input type="submit" /> </form> <div></div> <script> $(":input").select( function () { $("div").text(value).show().fadeOut(1000); }); </script> What I would like to do is build a simple jquery toolbar. I would like to get the selected text in the input box and replace it with for example: <strong>text</strong> Keep in mind that this is test code I'm not good with javascript or jquery. Need some help and tips please. Thanks
  2. Hi thanks, I tried it but still outputs: array array array array The result I'm looking for is: up down forward backwards How can I achieve that?
  3. Hi guys I'm struggling a bit, I need to replace a word that occurs multiple times in text with an array("up","down","forward","backwards") of words. $find = "left"; $replace = array("up","down","forward","backwards"); $text = "left left left left"; echo str_replace($find,$replace,$text); The Output is: array array array array Did try this with a foreach statement as well, but no luck. Is there a better way of doing this? Thanks
  4. Hi guys, I need some help installing Lucene with Mediawiki. I have two databases running on one source installation (symlinked). one is english and one is in another langauge. I've managed to get it working for the english version of the site, but getting it working for the second database is not working. I've managed to get the seccond database to index, but the search is not working. I'm using the MWsearch extension with Lucene. All I want to know is how can I set it properly to search the second database? Thanks in adavance.
  5. Hi Guys I'm trying to put a image into a rich textbox from a popup window(child) to the main window(parent window) that contains the rich textbox. What I'm doing is uploading the image via PHP to the server and then putting that image into an image tag <image>. Now I need to use Javascript to put that image into the parent window's rich textbox. I'm not good with Javascript at all, so all your help will be apreciated. Thanks in advance.
  6. Hi Guys, I trying to create a work around. I'm creating a new section like this =new section=. Now that will be the title and the body will be empty if I save the page. Once I go and edit any content above that section and save the page, then the section disappears. Is there some kind of work around that I can do not to lose that section with it's empty body? Thanks in advance
  7. Hi guys I want to change the way wordpress searches my site. I want to get wordpress to search only in the title and return all posts with the search term. Is there a way for me to get this done, I have searched through all the wordpress codex docs and can't find a solution, even tried Google. Some advise will be appreciated. Thanks in advance!
  8. Hi there, I'm new to drupal. I'm trying to get data to display when I do a db query. The problem is like this, when I return data I get nothing to display and when I echo on the my local xampp server it works but it's just giving a white page with the data I requested. When I do a return or echo on the live server nothing gets returned or echoed. The only thing that works is when I use drupal_set_message(t('<h2><a href="#">'.$title.'</a></h2>')); Here is my module code can somebody help me out? <?php // $Id$ /** * @file * Searching a database for articles. */ /** * Implementation of hook_menu(). */ function searchsae_menu() { $items['searchsae'] = array( 'title' => 'Search - SAE', 'page callback' => 'searchsae_page', 'access arguments' => array('access content'), ); return $items; } /** * Menu callback. * Called when user goes to http://example.com/?q=formexample */ function searchsae_page() { $output = t('Search SAE for articles.'); // Return the HTML generated from the $form data structure. $output .= drupal_get_form('searchsae_nameform'); return $output; } /** * Define a form. */ function searchsae_nameform() { $form['user_search'] = array( '#title' => t('Search'), '#type' => 'textfield', '#description' => t('Enter search terms.'), ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Searh') ); return $form; } /** * Validate the form. */ function searchsae_nameform_validate($form, &$form_state) { if ($form_state['values']['user_search'] == '') { // We notify the form API that this field has failed validation. form_set_error('user_search', t('You need to enter a search term!')); } } /** * Handle form submission. */ function searchsae_nameform_submit($form, &$form_state) { $search = $form_state['values']['user_search']; return search_output($search); } function search_output($search) { $result = db_query("SELECT articletitle FROM xml_import_db.articles_e WHERE articletitle like '%$search%' GROUP BY articletitle LIMIT 10"); // AND articleparagraph like '%$search%' //query 1 if(!empty($search)){ while($row = db_fetch_array($result)) { $title = array(); $xml = $row['articlexml']; $title = $row['articletitle']; $paragraph = $row['articleparagraph']; $replace = "<b>".$search."</b>"; //str_replace(" ", "-" , $title); //drupal_set_message(t("<h2>".$title."</h2>")); //echo t('<p>'.$title.'</p>'); //echo '<p>'.$title.'</p>'; //drupal_set_message(t('<h2><a href="#">'.$title.'</a></h2>')); //drupal_set_message(t("<p>".substr($paragraph, 0,500)."</p>")); //drupal_set_message(t("<p>".$xml."</p>")); echo $title; } //mysql_close($con); } elseif(empty($search)){ drupal_set_message(t('Query is empty!')); } }
  9. Hi, I tried something simular and tested yours still getting the error: Fatal error: Call to a member function getAttribute() on a non-object in
  10. Hi have written a script that runs through the xml document and gets the data of the requested nodes. then it stores the nodes in a mysql table. Now when I'm running the script I'm also looking for a attribute called "name" in a node called "PICTURE". The script runs and pulls all the xml files out of the specified directory (keep in mind all of the xml files has the same structure) and then uses the domdocument to read the nodes in the files. but when it comes to a xml document that does not have the "PICTURE" Node it starts tot get the following error: Fatal error: Call to a member function getAttribute() on a non-object in Is there a way to keep the script running even if there isn't a "PICTURE" node in the file, so that it ignores that field and still get the rest of the nodes in the file. THE XML WITHOUT IMAGE: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml-stylesheet type="text/xsl" href="#!-- #EXECUTIVE:HOME_PATH --#/Folio_xsl"?> <DOCUMENT source-infobase-name="A_Sae" content-collection-id="A_Sae" source-infobase-title="A_Sae" base-output-dir="F:\Projects\MigrationXML\Learning\XML\A_Sae_Output\" default-split-level="Alv" makefile-filename="F:\Projects\MigrationXML\Learning\XML\A_Sae_Output\A_Sae.mak" css-stylesheet-href="#!-- #STYLESHEETS:Stylesheet.CSS --#" xml-output-dir="F:\Projects\MigrationXML\Learning\XML\A_Sae_Output\XML\" makefile-document-depth="3"> <LEVEL style-name="8lv" style-name-escaped="lv" style-id="0-0-0-13" level-depth="3" toc-section="false"> <RECORD id="0-0-0-44" number="49" version="3"> <HEADING>Politieke arena</HEADING> <PARA style-name="pBold-Blue-11" style-name-escaped="pBold-Blue-11" style-id="0-0-0-37">Politieke arena</PARA> </RECORD> <LEVEL style-name="Normal Level" style-name-escaped="Normal-Level" style-id="0-0-0-0" level-depth="0" toc-section="false"> <RECORD id="0-0-0-47" number="50" version="84"> <PARA>Die klem op die bewaring van die eie (etniese of ander groepswaardes, taal, kultuur) het ook deurgesypel na die politieke arena, waar etniese konflik op byna elke vasteland tot sulke mate intensiveer het dat ingryping deur die internasionale gemeenskap telkens nodig geword het om verreikende skade weens die rimpeleffek in die globale arena te beperk. Hierdie ingryping neem die vorm aan van byvoorbeeld internasionale afgesante/bemiddelaars en vredesbewaringsendings deur die lidstate van die Verenigde Nasies (VN).</PARA> </RECORD> <RECORD id="0-0-0-250354" number="51" version="84"> <PARA>Dit geld in die een of ander vorm vir onder meer Soedan (Darfoer-streek) in Afrika en die Balkan in Europa, die Israelies-Palestynse konflik in die Midde-Ooste en internasionale ingrepe om Suid-Amerika uit sy ekonomiese moeras te help lig. In Europa het dit in sommige gevalle aanleiding gegee tot die herrysing van die ver-regsgesindes en diskriminasie teen immigrante uit arm lande, terwyl waarskuwingsliggies geflikker het toe jong immigrante in Parys in 2005 amok gesaai het oor hul uitsluiting van die Franse gemeenskap.</PARA> </RECORD> <RECORD id="0-0-0-250355" number="52" version="84"> <PARA>Die ekonomiese opgang van China en Indië, die heropkoms van Rusland en die sterker samehang van die Latyns-Amerikaanse blok het in 2007 die VSA se supermagstatus verder bedreig nadat dit klaar geknou is deur 'n plaaslike resessie. Amerika se globale politieke status is verder aangetas deur sy voortslepende militêre teenwoordigheid in Irak wat onstabiliteit in die Midde-Ooste eerder aangewakker het as om demokrasie en vrede te bring. Die Obama-administrasie, wat in 2008 die mag in die VSA oorgeneem het, het vroeë tekens getoon dat hulle die situasie aanspreek, met hoëvlak-onderhandelinge met Israel en Hamas nadat 'n brose skietstilstand weer in die slag gebly het.</PARA> </RECORD> <RECORD id="0-0-0-250356" number="53" version="84"> <PARA>Obama, wat die Nobelprys vir Vrede in 2009 ontvang het vir die "audacity of hope" (uitdagendheid van hoop) wat hy na die globale politieke verhoog gebring het, het ironies genoeg in sy aanvaardingtoespraak te kenne gegee dat 'n oorlogvrye wêreld nie altyd moontlik is nie. Dit is geïnterpreteer as 'n verwysing na die VSA se voortdurende teenwoordigheid in die Midde-Oosterse lande Irak en Afganistan, en sy vrese omtrent 'n kernbedreiging vanaf Iran. Obama het wel die VSA se verbintenis tot die inkrimping van sy kernarsenaal herhaal en aangekondig dat hy afsien van die "Star Wars"-ruimteskild teen kernwapens.</PARA> </RECORD> </LEVEL> </LEVEL> </DOCUMENT> XML WITH IMAGE: <DOCUMENT source-infobase-name="E_Sae" content-collection-id="E_Sae" source-infobase-title="South African Encyclopedia" base-output-dir="F:\Projects\MigrationXML\Learning\XML\E_Sae_Output\" default-split-level="Alv" makefile-filename="F:\Projects\MigrationXML\Learning\XML\E_Sae_Output\E_Sae.mak" css-stylesheet-href="#!-- #STYLESHEETS:Stylesheet.CSS --#" xml-output-dir="F:\Projects\MigrationXML\Learning\XML\E_Sae_Output\XML\" makefile-document-depth="1"> <LEVEL style-name="6lv" style-name-escaped="lv" style-id="0-0-0-7" level-depth="1" toc-section="false"> <RECORD id="0-0-0-1" number="1" version="3"> <HEADING>Contents</HEADING> <PARA style-name="pBold-Orange-12-Verd" style-name-escaped="pBold-Orange-12-Verd" style-id="0-0-0-43"> <PARAFORMAT tab-count="1"> <TABSTOP number="0" position="285" justification="left" leader="none"/> <[b]PICTURE[/b] id="0-0-0-123-img" object-class="folio objects" name="icon_sae.gif" href="#!-- #EXECUTIVE:HOME_PATH --#/img/icon_sae.gif" width="858" height="735" left-border-line-color="0" left-border-line-width="0" left-border-space="0" right-border-line-color="0" right-border-line-width="0" right-border-space="0" top-border-line-color="0" top-border-line-width="0" top-border-space="0" bottom-border-line-color="0" bottom-border-line-width="0" bottom-border-space="0"/>&#160; <DESTINATION id="0-0-0-125" name="E_Sae_Title"/>South African Encyclopedia<CHARSTYLE style-name="cBold-Orange-12-Verd" style-name-escaped="cBold-Orange-12-Verd" style-id="0-0-0-78"> </CHARSTYLE> <CHARSTYLE style-name="cHidden" style-name-escaped="cHidden" style-id="0-0-0-82">- Contents</CHARSTYLE> </PARAFORMAT> </PARA> </RECORD> <LEVEL style-name="Normal Level" style-name-escaped="Normal-Level" style-id="0-0-0-0" level-depth="0" toc-section="false"> <RECORD id="0-0-0-2" number="2" version="3"> <PARA style-name="pBold-Blue-bgLBlue-11" style-name-escaped="pBold-Blue-bgLBlue-11" style-id="0-0-0-39">Contents</PARA> </RECORD> <RECORD id="0-0-0-3" number="3" version="3"> <PARA>The South African Encyclopedia has been compiled from a South African perspective and with the needs of a new generation of South Africans in mind. To access the information:</PARA> </RECORD> <RECORD id="0-0-0-4" number="4" version="3"> <PARA style-name="pInd0.2-1.0-T1.0" style-name-escaped="pInd0-2-1-0-T1-0" style-id="0-0-0-57"> <CHARSTYLE style-name="cWingdings" style-name-escaped="cWingdings" style-id="0-0-0-90">Ø</CHARSTYLE> <TAB tab-count="1"/>Click on the categories below to expand the subcategories, then the sections (sometimes even subsections) and lastly open the articles. </PARA> </RECORD> <RECORD id="0-0-0-5" number="5" version="3"> <PARA style-name="pInd0.2-1.0-T1.0" style-name-escaped="pInd0-2-1-0-T1-0" style-id="0-0-0-57"> <CHARSTYLE style-name="cWingdings" style-name-escaped="cWingdings" style-id="0-0-0-90">Ø</CHARSTYLE> <TAB tab-count="1"/>The articles are also listed alphabetically in the Table of Contents on the left-hand side of your screen. Right-click with your mouse on "Contents" and "Expand all" to view the full alphabetical list.</PARA> </RECORD> <RECORD id="0-0-0-6" number="6" version="3"> <PARA style-name="pInd0.2-1.0-T1.0" style-name-escaped="pInd0-2-1-0-T1-0" style-id="0-0-0-57"> <CHARSTYLE style-name="cWingdings" style-name-escaped="cWingdings" style-id="0-0-0-90">Ø</CHARSTYLE> <TAB tab-count="1"/>Click on the article of your choice to go directly to its contents, or scroll down until you reach the desired article.<LINEBRK/> </PARA> </RECORD> <RECORD id="0-0-0-7" number="7" version="3"> <PARA> <TABLE> <TABLEFORMAT number-of-widths="2" horizontal-gap="72" left-indent="912" left-border-space="43" left-border-width="15" left-border-color="#C0C0C0" right-border-space="43" right-border-width="15" right-border-color="#C0C0C0" top-border-space="43" top-border-width="15" top-border-color="#C0C0C0" bottom-border-space="43" bottom-border-width="15" bottom-border-color="#C0C0C0"> <COLUMNFORMAT column-width="51" percentage="no"/> <COLUMNFORMAT column-width="232" percentage="no"/> </TABLEFORMAT> <ROW> <COL> <PARA style-name="pCenter" style-name-escaped="pCenter" style-id="0-0-0-52"> <CELLFORMAT bottom-border-space="0" bottom-border-width="15" bottom-border-color="#C0C0C0"> <CELL cells-merged-right="1"> <CHARSTYLE style-name="cBold-Orange-11" style-name-escaped="cBold-Orange-11" style-id="0-0-0-77">Table of Contents</CHARSTYLE> </CELL> </CELLFORMAT> </PARA> </COL> </ROW> <ROW> <COL> <PARA> <CELLFORMAT> </CELLFORMAT> </PARA> </COL> <COL> <PARA style-name="pInd0.2-1.0-T1.0" style-name-escaped="pInd0-2-1-0-T1-0" style-id="0-0-0-57"> <CELLFORMAT> <CHARSTYLE style-name="cWingdings" style-name-escaped="cWingdings" style-id="0-0-0-90">Ø</CHARSTYLE> <TAB tab-count="1"/> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <LINK style-name="Jump" style-name-escaped="Jump" style-id="0-0-0-94" type="Jump" destination-name="E_Sae_Foreword" destination-id="0-0-0-127">Foreword</LINK> </CHARSTYLE> </CELLFORMAT> </PARA> <PARA style-name="pInd0.2-1.0-T1.0" style-name-escaped="pInd0-2-1-0-T1-0" style-id="0-0-0-57"> <CHARSTYLE style-name="cWingdings" style-name-escaped="cWingdings" style-id="0-0-0-90">Ø</CHARSTYLE> <TAB tab-count="1"/> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <LINK style-name="Jump" style-name-escaped="Jump" style-id="0-0-0-94" type="Jump" destination-name="E_Sae_EditorMessage" destination-id="0-0-0-129">Editor's message</LINK> </CHARSTYLE> </PARA> <PARA style-name="pInd0.2-1.0-T1.0" style-name-escaped="pInd0-2-1-0-T1-0" style-id="0-0-0-57"> <CHARSTYLE style-name="cWingdings" style-name-escaped="cWingdings" style-id="0-0-0-90">Ø</CHARSTYLE> <TAB tab-count="1"/> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <LINK style-name="Jump" style-name-escaped="Jump" style-id="0-0-0-94" type="Jump" destination-name="E_Sae_Contributors" destination-id="0-0-0-131">Contributors</LINK> </CHARSTYLE> </PARA> </COL> </ROW> <ROW> <COL> <PARA style-name="pCenter" style-name-escaped="pCenter" style-id="0-0-0-52"> <CELLFORMAT> <PICTURE id="0-0-0-133-img" object-class="Folio Objects" name="Sci_Logo01z.jpg" href="#!-- #EXECUTIVE:HOME_PATH --#/img/Sci_Logo01z.jpg" width="573" height="465" left-border-line-color="0" left-border-line-width="0" left-border-space="0" right-border-line-color="0" right-border-line-width="0" right-border-space="0" top-border-line-color="0" top-border-line-width="0" top-border-space="0" bottom-border-line-color="0" bottom-border-line-width="0" bottom-border-space="0"/> </CELLFORMAT> </PARA> </COL> <COL> <PARA> <CELLFORMAT alignment="middle"> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <LINK style-name="Jump" style-name-escaped="Jump" style-id="0-0-0-94" type="Jump" destination-name="E_Sae_ScienceE" destination-id="0-0-0-135">Science and Technology</LINK> </CHARSTYLE> </CELLFORMAT> </PARA> </COL> </ROW> <ROW> <COL> <PARA style-name="pCenter" style-name-escaped="pCenter" style-id="0-0-0-52"> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <CELLFORMAT> </CELLFORMAT> </CHARSTYLE> <PICTURE id="0-0-0-137-img" object-class="Folio Objects" name="Soc_Logo01z.jpg" href="#!-- #EXECUTIVE:HOME_PATH --#/img/Soc_Logo01z.jpg" width="573" height="403" left-border-line-color="0" left-border-line-width="0" left-border-space="0" right-border-line-color="0" right-border-line-width="0" right-border-space="0" top-border-line-color="0" top-border-line-width="0" top-border-space="0" bottom-border-line-color="0" bottom-border-line-width="0" bottom-border-space="0"/> </PARA> </COL> <COL> <PARA> <CELLFORMAT alignment="middle"> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <LINK style-name="Jump" style-name-escaped="Jump" style-id="0-0-0-94" type="Jump" destination-name="E_Sae_SocietyE" destination-id="0-0-0-139">Society and the Humanities</LINK> </CHARSTYLE> </CELLFORMAT> </PARA> </COL> </ROW> <ROW> <COL> <PARA style-name="pCenter" style-name-escaped="pCenter" style-id="0-0-0-52"> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <CELLFORMAT> </CELLFORMAT> </CHARSTYLE> <PICTURE id="0-0-0-141-img" object-class="folio objects" name="projecttheme.gif" href="#!-- #EXECUTIVE:HOME_PATH --#/img/projecttheme.gif" width="858" height="597" left-border-line-color="0" left-border-line-width="0" left-border-space="0" right-border-line-color="0" right-border-line-width="0" right-border-space="0" top-border-line-color="0" top-border-line-width="0" top-border-space="0" bottom-border-line-color="0" bottom-border-line-width="0" bottom-border-space="0"/> </PARA> </COL> <COL> <PARA> <CELLFORMAT alignment="middle"> <CHARSTYLE style-name="cBold" style-name-escaped="cBold" style-id="0-0-0-69"> <LINK style-name="Jump" style-name-escaped="Jump" style-id="0-0-0-94" type="Jump" destination-name="E_Sae_ProjectFramework" destination-id="0-0-0-143">Project Framework</LINK> </CHARSTYLE> </CELLFORMAT> </PARA> </COL> </ROW> </TABLE> </PARA> </RECORD> <RECORD id="0-0-0-8" number="8" version="3"> <PARA style-name="pLine-Purple" style-name-escaped="pLine-Purple" style-id="0-0-0-65"> </PARA> </RECORD> </LEVEL> </LEVEL> </DOCUMENT> THE PHP CODE: <?php function get_links() { // connect to database $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xml_import_db", $con); /** *Get all XML files in the directory. */ $string=""; $fileCount=0; //$filePath=$PATH.'/home/holla22/public_html/superimtips.com/xml/xml/english/'; # Specify the path you want to look in. $filePath=$PATH.'\xampp\htdocs\sae\xml\afrikaans'; # The path of the directory $dir = opendir($filePath); # Open the path while ($file = readdir($dir)) { if (eregi("\.xml",$file)) { # Look for files with a .xml extension $string = "$file"; //$string[$fileCount] = $string; $fileCount++; echo $string; $resUrl = new DOMDocument(); $resUrl->load('xml/afrikaans/'.$string); //$prnt0 = 'entry'; $xmlResults = $resUrl->getElementsByTagName("DOCUMENT"); //if ($xmlResults->length<>0) { foreach($xmlResults as $value){ $pictures = $value->getElementsByTagName( "PICTURE" ); # IMAGES $picture = $pictures->item(0)->getAttribute('name'); $headings = $value->getElementsByTagName( "HEADING" ); # SUB HEADINGS $subheading = $headings->item(1)->nodeValue; $paras = $value->getElementsByTagName( "PARA" ); # MAIN HEADINGS $mainheading = $paras->item(0)->nodeValue; $levels = $value->getElementsByTagName( "LEVEL" ); # MAIN BODY TEXT level or $body = $levels->item(0)->nodeValue; } //$records = $value->getElementsByTagName( "RECORD" ); # IMAGES //$record = $records->item(0)->nodeValue; print_r("<p>".utf8_decode($picture)."</p>"); print_r("<p>".utf8_decode($mainheading)."</p>"); print_r("<p>".utf8_decode($subheading)."</p>"); //print_r("<p>".utf8_decode($record)."</p>"); print_r(utf8_decode("<p>".$body."</p>")); //escape and sanitize... $picture = mysql_real_escape_string($picture); # IMAGES $body = mysql_real_escape_string($body); # MAIN BODY TEXT $mainheading = mysql_real_escape_string($mainheading); # MAIN HEADINGS $subheading = mysql_real_escape_string($subheading); # SUB HEADINGS //insert into database //$q = "INSERT INTO articles_a1(articlexml, articletitle, articlesubheading, articlebody, articleimages) values ('$string', '$mainheading', '$subheading', '$body', '$picture')"; //$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); } } mysql_close(); #close connection echo "<h2>Data Imported Successfully</h2>"; } get_links(); ?>
  11. There is one more xml tag to that document and that is <HEADING> <LEVEL style-name="7lv" style-name-escaped="lv" style-id="0-0-0-10" level-depth="2" toc-section="false"> <RECORD id="0-0-0-9" number="9" version="3"> <HEADING>Voorwoord</HEADING> <PARA style-name="pBold-Purple-11" style-name-escaped="pBold-Purple-11" style-id="0-0-0-44"> <DESTINATION id="0-0-0-127" name="A_Sae_Voorwoord"/>Voorwoord</PARA> </RECORD> <LEVEL style-name="8lv" style-name-escaped="lv" style-id="0-0-0-13" level-depth="3" toc-section="false"> <RECORD id="0-0-0-10" number="10" version="3"> <HEADING>Die wêreld vandag</HEADING> <PARA style-name="pBold-Blue-11" style-name-escaped="pBold-Blue-11" style-id="0-0-0-37">Die wêreld vandag</PARA> </RECORD> Think of the XML as an article. The article has a heading / title, Description / body, pictures. so the title will be the <HEADING> tag, the body the <PARA> tag and the picture <PICTURE>. thanks
  12. This is my code: $picture = $row->getElementsByTagName( "PICTURE" ); $picture->item(0)->getAttribute('href'); I'm still getting that error -> Fatal error: Call to a member function getAttribute() on a non-object in.... Could it be because I'm using a local server for testing?
  13. Yes, all the xml files data will then be stored in variables, example: $title $description, $pictureurl. From there I need to store it in to a database table.
  14. thanks, but I'm still getting the error Call to undefined method DOMNodeList::getAttribute()
  15. here is a sample of the xml <RECORD id="0-0-0-11" number="11" version="94"> <PARA style-name="pCenter-8" style-name-escaped="pCenter-8" style-id="0-0-0-53"> <PICTURE id="0-0-0-25173-img" object-class="folio objects" name="SAE_Forward_09.jpg" href="#!-- #EXECUTIVE:HOME_PATH --#/img/SAE_Forward_09.jpg" width="6870" height="810" left-border-line-color="0" left-border-line-width="0" left-border-space="0" right-border-line-color="0" right-border-line-width="0" right-border-space="0" top-border-line-color="0" top-border-line-width="0" top-border-space="0" bottom-border-line-color="0" bottom-border-line-width="0" bottom-border-space="0"/> </PARA> </RECORD> <RECORD id="0-0-0-12" number="12" version="3"> <PARA> </PARA> </RECORD> <RECORD id="0-0-0-16" number="13" version="84"> <PARA>In 2009 het die wêreld weer stadig begin kop optel ná die globale resessie van die vorige jaar, maar kapitalisme se foutlyne is vir eens en altyd ontbloot, en dit was duidelik dat 'n volhoubare alternatief vir ongebreidelde verbruik gevind sou moet word. Die impak van die resessie - insluitende stygende werkloosheid, verergerende armoede en gekompromitteerde voedselsekuriteit - het 'n nuwe stel uitdagings vir beide ontwikkelende en ontwikkelde lande meegebring.</PARA> </RECORD> <RECORD id="0-0-0-250329" number="14" version="84"> <PARA>Die Amerikaanse president, Barack Obama, wat in 2008 die Withuis binnegeseil het op 'n golf van optimisme, moes toesien hoedat sy steun wegsypel terwyl hy gesukkel het om sy verkiesingsbeloftes uit te voer te midde van die voortslepende resessie en die harde werklikheid van globale politiek. Verrassend genoeg is die Nobel-prys vir Vrede in 2009 aan Obama toegeken, maar in sy aanvaardingstoespraak moes hy toegee dat dit in sommige gevalle nodig was om oorlog te maak om vrede te behaal - klaarblyklik 'n verwysing na die plofbare situasie in die Midde-Ooste, veral in Afganistan, waar 'n nuwe inspuiting van Amerikaanse troepe die onttrekkingsplanne voorafgegaan het.</PARA> </RECORD> <RECORD id="0-0-0-250330" number="15" version="84"> <PARA>Afrika het 'n kommerwekkende reeks staatsgrepe en voortslepende burgeroorloë beleef, maar aan die positiewe kant is die Libiese leier, Moeammar Ghaddafi, weerhou van 'n tweede termyn as president van die Afrika-Unie om sy planne vir 'n "Verenigde State van Afrika" onder sy leiding verder te voer. Vooruitgang is ook gemaak om Afrika-leiers wat misdade teen die mensdom gepleeg het, in plaaslike of internasionale howe aan die man te bring. In Zimbabwe het die Mugabe-Tsvangirai-koalisieregering egter steeds gesukkel om verligting vir sy mense te bring terwyl interne tweedrag voortgeduur het en internasionale sanksies in plek gebly het.</PARA> </RECORD> <RECORD id="0-0-0-250331" number="16" version="84"> <PARA>Aan die tuisfront was 2009 die aanbreek van 'n nuwe politieke era toe Jacob Zuma vir Kgalema Motlanthe opgevolg het as Suid-Afrika se nuwe president nadat die NVA klagtes van korrupsie teen hom laat vaar het. Zuma het aan die werk gespring deur die Kabinet te herskommel om opvoeding, gesondheid, werkloosheid, grondhervorming en plattelandse ontwikkeling te takel, maar teen die einde van die jaar het impak van die resessie saamgespan met swak dienslewering en korrupsie om stakings en insidente van gewelddadige protes deur misnoegde burgers te laat plaasvind.</PARA> </RECORD> <RECORD id="0-0-0-250332" number="17" version="84"> <PARA>Suid-Afrika betree 2010 met vuvuzelas gereed namate die 100-dae-aftel na die Fifa-sokkerwêreldbeker aanbreek. Die land - die eerste in Afrika om 'n Wêreldbeker aan te bied - was op skedule om 'n geraamde 500 000 besoekers te verwelkom by wat sonder twyfel een van die voorste sportgebeurtenisse op die planeet is.</PARA> </RECORD>
  16. Thanks but I think I stated my question wrong! I want to get all XML files from a directory, then I want all those XML files to be displayed with the dom. All files have the same structure.
  17. The XML : <LEVEL style-name="Normal Level" style-name-escaped="Normal-Level" style-id="0-0-0-0" level-depth="0" toc-section="false"> <RECORD id="0-0-0-11" number="11" version="94"> <PARA style-name="pCenter-8" style-name-escaped="pCenter-8" style-id="0-0-0-53"> <PICTURE id="0-0-0-25173-img" object-class="folio objects" name="SAE_Forward_09.jpg" href="#!-- #EXECUTIVE:HOME_PATH --#/img/SAE_Forward_09.jpg" width="6870" height="810" left-border-line-color="0" left-border-line-width="0" left-border-space="0" right-border-line-color="0" right-border-line-width="0" right-border-space="0" top-border-line-color="0" top-border-line-width="0" top-border-space="0" bottom-border-line-color="0" bottom-border-line-width="0" bottom-border-space="0"/> </PARA> </RECORD> <RECORD id="0-0-0-12" number="12" version="3"> <PARA> </PARA> </RECORD> <RECORD id="0-0-0-16" number="13" version="84"> <PARA>Test data.</PARA> </RECORD> <RECORD id="0-0-0-250329" number="14" version="84"> <PARA>Test Data</PARA> </RECORD> <RECORD id="0-0-0-250330" number="15" version="84"> <PARA>Test Data</PARA> </RECORD> <RECORD id="0-0-0-250331" number="16" version="84"> <PARA>test.</PARA> </RECORD> <RECORD id="0-0-0-250332" number="17" version="84"> <PARA>test</PARA> </RECORD> </LEVEL> What I want to do is get the the RECORD TAGS and the PICTURE TAGS attribute "href", my code : $doc = new DOMDocument(); $doc->load( 'xml/english/0-0-0-10.xml' ); //get xml data and display it, then store in to mysql table. //$rows = $doc->getElementsByTagName( "ROW" ); $rows = $doc->getElementsByTagName( "RECORD" ); foreach( $rows as $row ) { $links = $row->getElementsByTagName( "PARA" ); $link = $links->item(0)->nodeValue; $picture = $row->getElementsByTagName( "PICTURE" ); $pict = $picture->get_attribute('href'); echo "<p>$link</p><p>$pict</p>"; } I'm getting the following error Call to undefined method DOMNodeList::get_attribute() . What am I doing wrong?
  18. How can I get all files in a directory in to a array and then use that array to set each file in to a domDocument load? It will be used to output all the xml documents in a directory. Need direction please? /** *Get all XML files in the directory. */ $string=""; $fileCount=0; $filePath=$PATH.'/xampp/htdocs/sae/xml/english/'; # Specify the path you want to look in. $dir = opendir($filePath); # Open the path while ($file = readdir($dir)) { if (eregi("\.xml",$file)) { # Look for files with a .xml extension $string .= "$file<br />"; $string[$fileCount]; $fileCount++; } } //close the directory closedir(); if ($fileCount > 0) { echo sprintf("<strong>List of Files in %s</strong><br />%s<strong>Total Files: %s</strong>",$filePath,$string,$fileCount); $doc->load( 'xml/english/0-0-0-1001.xml' ); Thanks
  19. Hi Ken, Thank you very much, you're awesome It's working just the way I want it to work. Marking as solved!
  20. Hi there, Like the title says, I'm trying to save the XML data in a mysql table. The Table: `idbooks` INT NOT NULL AUTO_INCREMENT , `author` MEDIUMTEXT NULL , `publisher` MEDIUMTEXT NULL , `title` MEDIUMTEXT NULL , PRIMARY KEY (`idbooks`) ) The XML: <?xml version="1.0" encoding="UTF-8"?> <!-- This is just a comment, ignore it --> <books> <book> <author>Jack Herrington</author> <title>PHP Hacks</title> <publisher>O'Reilly</publisher> </book> <book> <author>Jack Herrington</author> <title>Podcasting Hacks</title> <publisher>O'Reilly</publisher> </book> </books> My Code: function get_links() { // connect to database $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("xml_import_db", $con); //set the dom file to load. $doc = new DOMDocument(); $doc->load( 'xml.xml' ); //get xml data and display it, then store in to mysql table. $books = $doc->getElementsByTagName( "book" ); foreach( $books as $book ) { $authors = $book->getElementsByTagName( "author" ); $author = $authors->item(0)->nodeValue; $publishers = $book->getElementsByTagName( "publisher" ); $publisher = $publishers->item(0)->nodeValue; $titles = $book->getElementsByTagName( "title" ); $title = $titles->item(0)->nodeValue; echo "$title - $author - $publisher<br />"; $title = serialize($title); $author = serialize($author); $publisher = serialize($publisher); $query = mysql_query("INSERT INTO books(author, publisher, title) values ('$author', '$publisher', '$title')"); echo $query; } //mysql_close(); //close connection //Return the links //return $links; } The data echo's correctly but the data does not get stored to my table, what am I doing wrong? Your help will be appreciated! Thanks guys.
  21. Awesome this is exactly the thing I'm looking for. Thanks for the help buddy
  22. Hi there, That is exactly what I'm looking for. I'm calling the names from the database, then those tags should somehow be converted to the names of each subscriber. Thanks
  23. I want to know how can I get php to recognize [name] tags to insert the person name in a email where ever I put the tag. What I do is I have a form with a textbox, inside the text box I type something like this: Dear [name], how are you to day? -------------- Now that should show the person name that I'm calling from mysql. How do I get php to do that?
  24. I have the following rules which is not working RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?sa-tourism\. [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(.+)\.google\. [NC] RewriteRule ^(.*)\.(gif|jpe?g|png)$ http://%{HTTP_HOST}/images/hotlink.jpg [R,NC,L] I want to redirect this www.domain.com/sa-tourism/wp-content/uploads/2009/03/vuvuzela.jpg to the hotlink image? What am I doing wrong, my images not redirecting to the hotlink image Thanks
  25. I need to know how to check if dates are older than 2 weeks. Then needs to delete rows older than 2 weeks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.