malhenry
2006-05-16 15:26:02 UTC
Please note I am using VS C++ 6.0 and NOT .NET.
I am getting zero for my count of nodes in the list returned by selectNodes.
It looks like I need to call setProperty(SelectionLanguage,"XPath") first,
but in my code below, setProperty is NOT a valid method for the pDoc object.
Any suggestions on what I can do?
HRESULT APCCheckXML::LoadDocumentSync(MSXML::IXMLDOMDocument* pDoc, BSTR
pBURL)
{
MSXML::IXMLDOMParseError* pXMLError = NULL;
VARIANT vURL;
VARIANT_BOOL vb; // valid vars are zero and MINUS one
HRESULT hr;
CHECKHR(pDoc->put_async(VARIANT_FALSE));
CHECKHR(pDoc->put_validateOnParse(VARIANT_FALSE));
// Load xml document from the given URL or file path
VariantInit(&vURL);
vURL.vt = VT_BSTR;
V_BSTR(&vURL) = pBURL;
// Note if vURL contains a non-existent file or does not have the full file
path
// you will get 3 occurrences of:
// First-chance exception in capgen.exe (KERNEL32.DLL): 0xE0000001: (no
name).
CHECKHR(pDoc->load(vURL, &vb));
CHECKHR(CheckLoad(pDoc));
CleanUp:
SAFERELEASE(pXMLError);
return hr;
}
// Here is the XPath call from another method that does not work
hr = pTraStatisticsNode->selectNodes((unsigned short *"//Tra/incident"),
&pXMLChildNodeList);
Here is the xml file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <Tra>
<date>06-05-15</date>
<time>08:40:25</time>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>401</route>
<direction>WB Express</direction>
<location>between</location>
<route>Jane</route>
<incident>Construction</incident>
<lane>Right lane</lane>
</incident>
<city>TO</city>
<sector>CE</sector>
- <incident>
<active>1</active>
<route>Gerrard</route>
<direction>Both ways</direction>
<location>east of</location>
<route>Coxwell</route>
<incident>Construction</incident>
<lane>Right lane</lane>
</incident>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>401</route>
<direction>EB Col-Exp</direction>
<location>at</location>
<route>400</route>
<incident>Closed repairs</incident>
<lane />
</incident>
<city>TO</city>
<sector>NC</sector>
- <incident>
<active>1</active>
<route>Yonge</route>
<direction />
<location>at</location>
<route>407</route>
<incident>Broken watermain</incident>
<lane />
</incident>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>Sheppard</route>
<direction />
<location>east of</location>
<route>Bathurst</route>
<incident>Closed repairs</incident>
<lane>All Lanes</lane>
</incident>
<city>TO</city>
<sector>SE</sector>
- <incident>
<active>1</active>
<route>DVP</route>
<direction>SB</direction>
<location>at</location>
<route>Don Roadway</route>
<incident>Lights out</incident>
<lane />
</incident>
<city>TO</city>
<sector>NW</sector>
- <incident>
<active>1</active>
<route>7</route>
<direction />
<location>at</location>
<route>Jane</route>
<incident>Closed repairs</incident>
<lane>All Lanes</lane>
</incident>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>Yonge</route>
<direction>NB</direction>
<location>past</location>
<route>Lawrence</route>
<incident>Collision</incident>
<lane />
</incident>
<city>TO</city>
<sector>CW</sector>
- <incident>
<active>1</active>
<route>400</route>
<direction>SB</direction>
<location>at</location>
<route>401</route>
<incident>Collision</incident>
<lane>Center lane</lane>
</incident>
<city>TO</city>
<sector>SW</sector>
- <incident>
<active>1</active>
<route>Gardiner</route>
<direction>EB Collect</direction>
<location>approach</location>
<route>Islington</route>
<incident>Collision</incident>
<lane>Right lane</lane>
</incident>
</Tra>
I am getting zero for my count of nodes in the list returned by selectNodes.
It looks like I need to call setProperty(SelectionLanguage,"XPath") first,
but in my code below, setProperty is NOT a valid method for the pDoc object.
Any suggestions on what I can do?
HRESULT APCCheckXML::LoadDocumentSync(MSXML::IXMLDOMDocument* pDoc, BSTR
pBURL)
{
MSXML::IXMLDOMParseError* pXMLError = NULL;
VARIANT vURL;
VARIANT_BOOL vb; // valid vars are zero and MINUS one
HRESULT hr;
CHECKHR(pDoc->put_async(VARIANT_FALSE));
CHECKHR(pDoc->put_validateOnParse(VARIANT_FALSE));
// Load xml document from the given URL or file path
VariantInit(&vURL);
vURL.vt = VT_BSTR;
V_BSTR(&vURL) = pBURL;
// Note if vURL contains a non-existent file or does not have the full file
path
// you will get 3 occurrences of:
// First-chance exception in capgen.exe (KERNEL32.DLL): 0xE0000001: (no
name).
CHECKHR(pDoc->load(vURL, &vb));
CHECKHR(CheckLoad(pDoc));
CleanUp:
SAFERELEASE(pXMLError);
return hr;
}
// Here is the XPath call from another method that does not work
hr = pTraStatisticsNode->selectNodes((unsigned short *"//Tra/incident"),
&pXMLChildNodeList);
Here is the xml file:
<?xml version="1.0" encoding="ISO-8859-1" ?>
- <Tra>
<date>06-05-15</date>
<time>08:40:25</time>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>401</route>
<direction>WB Express</direction>
<location>between</location>
<route>Jane</route>
<incident>Construction</incident>
<lane>Right lane</lane>
</incident>
<city>TO</city>
<sector>CE</sector>
- <incident>
<active>1</active>
<route>Gerrard</route>
<direction>Both ways</direction>
<location>east of</location>
<route>Coxwell</route>
<incident>Construction</incident>
<lane>Right lane</lane>
</incident>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>401</route>
<direction>EB Col-Exp</direction>
<location>at</location>
<route>400</route>
<incident>Closed repairs</incident>
<lane />
</incident>
<city>TO</city>
<sector>NC</sector>
- <incident>
<active>1</active>
<route>Yonge</route>
<direction />
<location>at</location>
<route>407</route>
<incident>Broken watermain</incident>
<lane />
</incident>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>Sheppard</route>
<direction />
<location>east of</location>
<route>Bathurst</route>
<incident>Closed repairs</incident>
<lane>All Lanes</lane>
</incident>
<city>TO</city>
<sector>SE</sector>
- <incident>
<active>1</active>
<route>DVP</route>
<direction>SB</direction>
<location>at</location>
<route>Don Roadway</route>
<incident>Lights out</incident>
<lane />
</incident>
<city>TO</city>
<sector>NW</sector>
- <incident>
<active>1</active>
<route>7</route>
<direction />
<location>at</location>
<route>Jane</route>
<incident>Closed repairs</incident>
<lane>All Lanes</lane>
</incident>
<city>TO</city>
<sector>CC</sector>
- <incident>
<active>1</active>
<route>Yonge</route>
<direction>NB</direction>
<location>past</location>
<route>Lawrence</route>
<incident>Collision</incident>
<lane />
</incident>
<city>TO</city>
<sector>CW</sector>
- <incident>
<active>1</active>
<route>400</route>
<direction>SB</direction>
<location>at</location>
<route>401</route>
<incident>Collision</incident>
<lane>Center lane</lane>
</incident>
<city>TO</city>
<sector>SW</sector>
- <incident>
<active>1</active>
<route>Gardiner</route>
<direction>EB Collect</direction>
<location>approach</location>
<route>Islington</route>
<incident>Collision</incident>
<lane>Right lane</lane>
</incident>
</Tra>