CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2012
    Posts
    1

    Read XML with C#

    Hey guyz,

    my problem: I want to read a XML file and get the text of a node. But my VS2008 gives me an error and i don't know how to handle it.

    This is my function
    Code:
            /// <summary>
            /// Liest den Namen eines Templates.
            /// </summary>
            /// <param name="p_strFile"></param>
            /// <returns></returns>
            public string ReadTemplateDetailsName(string p_strFile)
            {
                string l_erg = "";
     
                if (File.Exists(p_strFile))
                {
     
                    XmlDocument l_xmlDoc = new XmlDocument();
                    l_xmlDoc.Load(p_strFile);
                    XmlNode node = l_xmlDoc.SelectSingleNode("/name");
                    l_erg = node.InnerText;
                }
     
                return l_erg;
            }
    This is the beginning of my XML file
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE install PUBLIC "-//Joomla! 1.5//DTD template 1.0//EN" "http://dev.joomla.org/xml/1.5/template-install.dtd">
    <install version="1.5" type="template">
        <name>themza_j15_74</name>
        <version>1.0.0</version>
        <creationDate>2011-03-29</creationDate>
        <author>Themza Team</author>
    And this is my error:
    Code:
     the remote name could not be resolved: 'dev.joomla.org'
    How to handle this exception?

  2. #2
    Join Date
    Jan 2007
    Posts
    491

    Re: Read XML with C#

    Seems like this XML document is not valid...
    Either find out where the dtd file referred in the second row of your XML document is located (appearantly it's not in dev.joomla.org/something), Or removing the DOCTYPE element from your document (but then you won't be able to know that this document is valid according to that DTD)

  3. #3
    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    43

    Re: Read XML with C#

    Try downloading the DTD file to a local folder and change the URI in the XML file accordingly.
    Maybe it is just a problem of accessing it on the internet?

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured