dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Urgent: XML path

  1. #1
    Join Date
    May 2015
    Posts
    213

    Urgent: XML path

    Hi,

    I had asked a Q about loading the xml from a path. But then, I thought this wil work implicitly. But now im testing my code with the client and ah ! no its not working.

    Code:
    function( BSTR * path)
    {
    	HRESULT hr = CoInitialize(NULL);
    
    	MSXML2::IXMLDOMDocumentPtr pXMLDom;
    	MSXML2::IXMLDOMDocumentPtr pXSLDoc;
    	MSXML2::IXMLDOMDocumentPtr pXMLOut;
    	
        std::wstring pathofXmls(*modelList);
    	
        xmlName = "\\Bob.xml";
        xmlInfo +=  xmlName;
    	
    	pXMLDom->load(L"xmlInfo");
    	
    }
    In the above function, receive the input
    pathofXmls = L"F:\\Temp\\New\\x64\\Debug"

    Now I see the xml is not getting loaded.

    But on the other hand if i put the xml in the current directory, it gets loaded properly.

    @kaud: please help me

  2. #2
    Join Date
    May 2015
    Posts
    213

    Re: Urgent: XML path

    Just to update: I tried directly giving the path:
    pXMLDom->load(L"F:\\Temp\\New\\x64\\Debug\/xmlinputfile.xml");

    And it works.

    Now i was trying to deduce this from the input path:

    std:wstring ListXml(L"\/xmlinputfile.xml");

    pathofXmls = pathofXmls + (L"\") + mListXml;

    does not work

    neither pathofXmls +=xmlName ;

  3. #3
    Arjay's Avatar
    Arjay is online now Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,146

    Re: Urgent: XML path

    The following definitely won't work, unless you are trying to load an file named, "xmlInfo" with no file extension that happens to be in the current directory.
    Code:
    pXMLDom->load(L"xmlInfo")
    At any rate, use the debugger, step through your code and inspect the contents of the variables to make sure they contain what you think they should contain.

    Quite often, the problem is a simple mistake (like the one above) and using the debugger will help you find them.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Urgent: XML path

    Quote Originally Posted by pdk5 View Post
    Hi,

    I had asked a Q about loading the xml from a path. But then, I thought this wil work implicitly. But now im testing my code with the client and ah ! no its not working.

    Code:
    function( BSTR * path)
    {
    	HRESULT hr = CoInitialize(NULL);
    
    	MSXML2::IXMLDOMDocumentPtr pXMLDom;
    	MSXML2::IXMLDOMDocumentPtr pXSLDoc;
    	MSXML2::IXMLDOMDocumentPtr pXMLOut;
    	
        std::wstring pathofXmls(*modelList);
    	
        xmlName = "\\Bob.xml";
        xmlInfo +=  xmlName;
    	
    	pXMLDom->load(L"xmlInfo");
    	
    }
    And what are you passing in the load(...)? The file name L"xmlInfo", not the file path/name contained in the xmlInfo variable!
    Is it what you wanted?
    Victor Nijegorodov

  5. #5
    Join Date
    May 2015
    Posts
    213

    Re: Urgent: XML path

    Thanks Arjay,

    I tried giving the path directly:
    pXMLDom->load(L"F:\\Temp\\New\\x64\\Debug\/xmlinputfile.xml");

    And it works.

    My issues is , i get the
    BSTR * pathofXmls
    and its coming in as
    wstring pathofXmls = "F:\\Temp\\New\\x64\\Debug"

    I need to get the xmlinputfile from this path:
    std:wstring NameOfxml(L"\/xmlinputfile.xml");

    wstring fullpath = pathofXmls +NameOfxml;

    It always puts two extra \\ at end of pathofXmls

  6. #6
    Join Date
    May 2015
    Posts
    213

    Re: Urgent: XML path

    To make it simple (sorry i was writting in sleep yesterday)
    From :
    wstring pathofXmls = "F:\\Temp\\New\\x64\\Debug"
    wstring nameofxml = "Bob.xml"

    I want to get : wstring fullpath = "F:\\Temp\\New\\x64\\Debug\/Bob.xml"

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Urgent: XML path

    Quote Originally Posted by pdk5 View Post
    To make it simple (sorry i was writting in sleep yesterday)
    From :
    wstring pathofXmls = "F:\\Temp\\New\\x64\\Debug"
    wstring nameofxml = "Bob.xml"

    I want to get : wstring fullpath = "F:\\Temp\\New\\x64\\Debug\/Bob.xml"
    But why "F:\\Temp\\New\\x64\\Debug\/Bob.xml",
    not the "F:\\Temp\\New\\x64\\Debug\\Bob.xml"?
    Victor Nijegorodov

  8. #8
    Join Date
    May 2015
    Posts
    213

    Re: Urgent: XML path

    SORRY GUYS. Now figured out the issue.
    Sorry was doing too many things at same time.

    Thanks a lot for this forum, forgiving me for asking these Qs.

    And again this is friendliest and great forum, without which i would never have struggled lot to do c++ coding.
    Last edited by pdk5; October 24th, 2019 at 03:44 AM.

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,543

    Re: Urgent: XML path

    Quote Originally Posted by pdk5 View Post
    SORRY GUYS. Now figured out the issue.
    ...
    Could you explain us how did you figure it out?
    Victor Nijegorodov

  10. #10
    Join Date
    May 2015
    Posts
    213

    Re: Urgent: XML path

    "wstring pathofXmls = "F:\\Temp\\New\\x64\\Debug"" is working !!!.

    Not sure yesterday somehow i culdnot get it working (ofcourse i was doing many things). Very sorry

  11. #11
    Arjay's Avatar
    Arjay is online now Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,146

    Re: Urgent: XML path

    Quote Originally Posted by pdk5 View Post
    "wstring pathofXmls = "F:\\Temp\\New\\x64\\Debug"" is working !!!.

    Not sure yesterday somehow i culdnot get it working (ofcourse i was doing many things). Very sorry
    It wasn't working because you had the goofy \/ characters in the path as Victor pointed out in post #7. This is why you should use a debugger and step through your code to inspect the variables.
    Last edited by Arjay; October 24th, 2019 at 05:52 AM.

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)