CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Location
    India
    Posts
    63

    Namespace in XPATH

    Code:
    <?
    Code:
    xmlversion="1.0"?><a:multistatusxmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"xmlns:d="urn:schemas:httpmail:"xmlns:c="xml:"xmlns:a="DAV:">
    <a:response>
    <a:href>http://server/exchange/talksandy/</a:href>
    <a:propstat>
    <a:status>HTTP/1.1 200 OK</a:status>
    <a:prop>
    <d:drafts>http://server/exchange/talksandy/Drafts</d:drafts>
    </a:prop>
    </a:propstat>
    </a:response>
    </a:multistatus>



    How can I select drafts element using C#.
    I tried using following code
    Code:
    XmlDocument doc = newXmlDocument();
    doc.LoadXml(reader.ReadToEnd());
    XmlNamespaceManager namespaceManager = newXmlNamespaceManager(doc.NameTable);
    namespaceManager.AddNamespace("mail", "urn:schemas:httpmail:");
    namespaceManager.AddNamespace("a", "DAV:");
    XmlElement element = doc.SelectSingleNode("/a:response/a:propstat/a:prop/mail:drafts",namespaceManager) as XmlElement;


    But this code is not working. Here reader contains the XML I provided above.
    Please help.
    Thanks
    Sandeep
    http://www.sandeeprawat.com
    Code:
    Forget the language. Remember the logic.

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: Namespace in XPATH

    It seems that your xpath expression is wrong. What if you try this?
    Code:
    /a:multistatus/a:response/a:propstat/a:prop/mail:drafts
    - petter

  3. #3
    Join Date
    Nov 2004
    Location
    India
    Posts
    63

    Re: Namespace in XPATH

    Yeah. I dont know how I forgot to c that multistatus messed up in the first line with xml tag

    Thanks anyway.
    Sandeep
    http://www.sandeeprawat.com
    Code:
    Forget the language. Remember the logic.

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