Menu

Unable to open my xml file?

danpsy
2011-09-05
2025-04-05
  • danpsy

    danpsy - 2011-09-05

    Here is what I'm currently working with:

    TiXmlDocument doc("test.xml");
    if (doc.LoadFile())
    {
        std::cout << "woo" << std::endl;
        //std::cout << doc.RootElement() -> FirstChildElement() -> Attribute("tag") << std::endl;
    }
    else
    {
        std::cout << "no :(" << std::endl;
    }
    

    test.xml looks like:

    <test>
        <tag>lolol</tag>
    </tes>
    

    Of course I'm also including "tinyxml.h" at the top.

    "no :(" is always returned.  test.xml is in the same directory as my application's binary file.  I'm not sure if anything is directly obvious, but I'm not able to figure out what the issue might be.

    Thanks for any help!

     
  • danpsy

    danpsy - 2011-09-06

    Wow how silly, it seems that my open <test> and close </test> tag didn't match.  (Close tag lacking a "t," only being </tes).

    That's really handy that it won't open the file if there is an issue (like not a matching closing tag), it makes it easier to report parsing errors.

     
  • Neil James

    Neil James - 2025-04-05

    What happens when you try to open the XML file?

    Do you get an error message? If yes, what does it say exactly?

    How are you trying to open the XML file?

    With a specific program (Notepad, Excel, Browser, VS Code, etc.)?

    What is the file size of the XML file?

    Is it unusually large?

    Can you share a sample (non-sensitive) part of the XML file content?

    Sometimes errors are due to missing tags or corruption.

    Common Solutions:
    Issue Solution
    File won't open in browser Right-click → Open With → Notepad or VS Code
    Excel can't open XML Open Excel → File → Open → Select "XML Files"
    File shows error like "Invalid XML" Check for missing <tags> or syntax errors
    Large File Size Use a text editor like Notepad++ or VS Code
    File Encoding Issue Open in Notepad → Save As → Choose UTF-8 encoding
    If corrupted:
    You can upload the file here, or copy a part of it (without sensitive info), and I can help fix or clean it.</tags>

    Would you like to:

    Repair the XML?

    View it properly?

    Convert it to another format (Excel, JSON, CSV)?

    Validate if the XML is correct?

    Let me know!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.