Problem parsing XML

Discussion in 'PHP' started by risoknop, Jul 2, 2009.

  1. #1
    Here's the XML I want to parse:

    http://www.wowarmory.com/character-sheet.xml?r=Nazjatar&n=Underdeath
    Code (markup):
    And here's how I'm trying to parse it:

    $xml = simplexml_load_file('http://www.wowarmory.com/character-sheet.xml?r=Nazjatar&n=Underdeath');
    PHP:
    I get this error:

    ... parser error : StartTag: invalid element name in ...
    Code (markup):
    Any suggestions?
     
    risoknop, Jul 2, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Try this to debug.

    
    
    $xml_file = file_get_contents('http://www.wowarmory.com/character-sheet.xml?r=Nazjatar&n=Underdeath');
    
    echo "<pre>";
    echo $xml_file;
    echo "</pre>";
    
    //$xml = simplexml_load_string($xml_file);
    
    
    PHP:
    Look at the source and see if the xml is correctly formatted.
     
    jestep, Jul 2, 2009 IP
  3. gunbound

    gunbound Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
  4. mdrobiul

    mdrobiul Peon

    Messages:
    186
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    that's a xml and you're right. what I think about this that today people also make webpages in xml file and you can apply style with css in xml file. xml may be used for storing special data. xml is now there being used for showing web content. they might apply xsl etc.. you just need to study on this issuess...
     
    mdrobiul, Jul 3, 2009 IP
  5. risoknop

    risoknop Peon

    Messages:
    914
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes they are using xsl. I have already figured it out by the way, the problem was they are serving different content for different web browsers. I just needed to define a user agent as Firefox with cURL.
     
    risoknop, Jul 4, 2009 IP