Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: How to use XPATH on SVG? How to use XPATH on SVG?To: NULL Date: 11/4/2008 9:28:00 PM Below is a simplified version of the file from which I am trying to use
XPATH to extract some values. My code seems to work with no namespaces but
the SVG namespaces are messing me up (I think).
Here is my XPATH I'm trying to parse with MSXML2. I've tried it with and
without the "svg:" and it does not work.
Thanks!
Siegfried
_bstr_t bstrQuery(
//L"/html/body/form/table/tbody/tr[2]/td/svg:svg/svg:g/svg:text/[@class=\"tch\"]"
L"/html/svg:svg/svg:g/svg:text/[@class=\"tch\"]"
);
MSXML2::IXMLDOMNodeListPtr pNodeList;
pNodeList = pXMLDoc->selectNodes(bstrQuery);
long lLen = 0;
HRESULT hr = pNodeList->get_length(&lLen);
if ( SUCCEEDED(hr) )
{
for (int i = 0; i < lLen; i++)
{
MSXML2::IXMLDOMNodePtr pXMLNode;
pNodeList->get_item(i,&pXMLNode);
// Get some attribute as an example
_variant_t vNodeValue;
hr = pXMLNode->get_nodeValue(&vNodeValue);
MSXML2::IXMLDOMNodeListPtr pNodeList = pXMLNode->childNodes;
long lLen2 = pNodeList->length;
for(int jj = 0; jj < lLen2; ++jj)
{
MSXML2::IXMLDOMNodePtr pXMLNode;
pNodeList->get_item(jj,&pXMLNode);
_bstr_t text;
text = pXMLNode->text;
TraceW(L" item = %d\n", ((LPCWSTR)text)[0L]);
}
MSXML2::IXMLDOMElement *pNodeElm = NULL;
hr = pXMLNode->QueryInterface(IID_IXMLDOMElement, (void**)&pNodeElm);
if ( SUCCEEDED(hr) )
{
vNodeValue = pNodeElm->getAttribute(L"x");
_bstr_t text = vNodeValue;
TraceW(L"x=%s", (LPCWSTR)text);
pNodeElm->Release();
}
}
}
}
Here is the XML:
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" x="0mm" y="0mm" width="500mm"
height="390.mm" viewBox="0 0 500 390" enable-background="new 0 0 1390.076
390.208" xml:space="preserve">
<g transform="translate( 40.00, 59.55)"><rect id="line 1277 rect"
title="0002 0001 scan 001 ` ~" width="12.5" height="12.5"
class="keyoutline" /> <text x=" 1" y=" 5" class="common-up"
text-anchor="middle">~</text><text x=" 1" y="11" class="common">`</text>
<text x=" 6" y="11" class="tch">巷</text><text x=" 6" y="11"
class="ru-up">Ȅ</text><text x=" 6" y="11" class="ru-lo">ȅ</text>
</g>
</svg>
</html>
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
