SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML DOM question

    how do I tell the DOM not to attempt to parse an XML file if it's invalid? I'll get warnings like this: "Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Space required after the Public Identifier in Entity, line: 1 in..." and such. below is the code that I've been using:
    PHP Code:
    $dom=new DomDocument();
        
    $dom->preserveWhiteSpace false;
        
    $dom->validateOnParse=false;
        
    //$dom->loadXML($fxml);
        
    $fxml=trim($fxml);
        
    //echo $fxml;
        
        
    if($dom->loadXML($fxml)==false){
    ... 
    any tips?

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I'm afraid the only way is suppressing the warnings:
    Code php:
    if(@$dom->loadXML($fxml)==false){
    Yes, php is that stupid for having exceptions and not making use of them.
    Saul

  3. #3
    SitePoint Wizard bbolte's Avatar
    Join Date
    Nov 2001
    Location
    The Central Plains
    Posts
    3,304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yeah prolly. it's a weird warning. back in my MS days, the dom reader would just not load it if it wasn't valid xml and give me a false return. thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •