Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. Problem with MSXML6 + namespace + XPath

Problem with MSXML6 + namespace + XPath

Scheduled Pinned Locked Moved XML / XSL
xmlc++databasedata-structuresperformance
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Patrice Espie
    wrote on last edited by
    #1

    Hi All, I try to use MSXML with xml files which contains namespaces. But I can't figure out how to do! Here is an excerpt of my XML file: <?xml version="1.0" encoding="utf-8"?> <BENCH xmlns:VODPC_VOD="urn:VODPC:VOD:schema:20060809"> <VODPC_VOD:GRAPH state="running" currentFlowID="1" removeOnExit="FALSE"> </VODPC_VOD:GRAPH> </BENCH> When I load the file with MSXML6, no problem. I try to access node BENCH with XPath "/BENCH" : no problem. But when I try to access node VODPC_VOD:GRAPH with XPath "/BENCH/VODPC_VOD:GRAPH", I get an exception, which contain no valuable information: First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: Microsoft C++ exception: _com_error at memory location 0x0025dac4.. I set these flags before to load: m_pXMLDoc->async = VARIANT_FALSE; m_pXMLDoc->preserveWhiteSpace = VARIANT_TRUE; m_pXMLDoc->validateOnParse = VARIANT_TRUE; m_pXMLDoc->resolveExternals = VARIANT_TRUE; As you can understand, I work in C++. I'm an IT profesionnal since 18 year. My problem is that I do not know what namespace is used in the file, so I don't want to have to tell MSXML6 what namespaces are used IN THE FILE. I guess it's its job, no ? If anybody have an idea ... Thanks a lot Patrice

    S 1 Reply Last reply
    0
    • P Patrice Espie

      Hi All, I try to use MSXML with xml files which contains namespaces. But I can't figure out how to do! Here is an excerpt of my XML file: <?xml version="1.0" encoding="utf-8"?> <BENCH xmlns:VODPC_VOD="urn:VODPC:VOD:schema:20060809"> <VODPC_VOD:GRAPH state="running" currentFlowID="1" removeOnExit="FALSE"> </VODPC_VOD:GRAPH> </BENCH> When I load the file with MSXML6, no problem. I try to access node BENCH with XPath "/BENCH" : no problem. But when I try to access node VODPC_VOD:GRAPH with XPath "/BENCH/VODPC_VOD:GRAPH", I get an exception, which contain no valuable information: First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: 0xE0000001: 0xe0000001. First-chance exception at 0x75ac9617 in XXXXXX.exe: Microsoft C++ exception: _com_error at memory location 0x0025dac4.. I set these flags before to load: m_pXMLDoc->async = VARIANT_FALSE; m_pXMLDoc->preserveWhiteSpace = VARIANT_TRUE; m_pXMLDoc->validateOnParse = VARIANT_TRUE; m_pXMLDoc->resolveExternals = VARIANT_TRUE; As you can understand, I work in C++. I'm an IT profesionnal since 18 year. My problem is that I do not know what namespace is used in the file, so I don't want to have to tell MSXML6 what namespaces are used IN THE FILE. I guess it's its job, no ? If anybody have an idea ... Thanks a lot Patrice

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      You have to tell MSXML what namespace prefixes your XPath expressions use. When parsing XML, the parser remmebers the namespace URIs, NOT the prefixes used in the documents. That means that your code has to define the prefix to URI mappings used in your XPaths.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups