locked
How to parse the following xml and retrieve nodes

    Question

  • Hi,

    I have the following xml :

    <?xml version="1.0" encoding="utf-8" standalone="no"?>
    <container xmlns="urn:oasis:names:tc:opendocument:xmlns:container" version="1.0">
    	<rootfiles>
    		<rootfile full-path="EPUB/package.opf" media-type="application/oebps-package+xml"/>
    	</rootfiles>
    </container>
    

    and I am trying this to get the rootfile element :

    XmlDocument^ xmlDoc = ref new XmlDocument;
    	xmlDoc->LoadXml(xmlStr, xmlSettings);
    	Platform::Object^ nsUri = xmlDoc->NamespaceUri;
    	auto nodes = xmlDoc->SelectNodesNS("/ns:container/ns:rootfiles/ns:rootfile", "xmlns:ns=\"urn:oasis:names:tc:opendocument:xmlns:container\"");
    	if (nodes != nullptr)
    	{
    
    	}

    But it doesn't work...

    How should I do ?

    I also don't understand the type returned by NamespaceUri because it's a Platform::Object but don't know how to cast it to something else, maybe a Windows::Foundation::Uri ? I tried a simple C cast and it doesn't compile but maybe I need to use the static/reinterpret/dynamic casts ?

    Thanks

    Monday, February 03, 2014 12:46 PM

Answers

All replies

  • OK I found I need to use L""
    • Marked as answer by Vincent Rich Monday, February 03, 2014 1:11 PM
    Monday, February 03, 2014 1:11 PM
  • Yes, Wide string literals, represented as L"xxx" (C++ String Literals). Thank you for sharing the answer :)

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Tuesday, February 04, 2014 2:08 AM
    Moderator