d***@gmail.com
2008-01-31 15:11:54 UTC
Hello
I'm working on a product that is using XmlLite. Following the example
given by Microsoft on their website (http://msdn2.microsoft.com/en-us/
library/ms753116(VS.85).aspx) I have made a while loop that calls
IXmlReader::Read() and switches on the nodeType gotten. In the
example, they use IXmlReader::IsEmptyElement() to determine if a node
looks like this:
<nodeName attributeName="attributeValue" />
As I am walking through a hierarchical XML, I need to know when a node
ends. So I have both that call to IXmlReader::IsEmptyElement() and
code in the case for XmlNodeType_EndElement that walks me back up to
the parent.
Unfortunately, I am not seeing IXmlReader::IsEmptyElement() returning
true ever. The node it is reading in my testing is this:
<parameterType name="stringParameter" type="string"
multiValued="false" />
And the code reading that node is effectively this:
while(S_OK == (hr = xmlReader->Read(&nodeType)))
{
switch(nodeType)
{
case XmlNodeType_Element:
{
if(FAILED(hr = xmlReader->GetLocalName(&nodeName, NULL)))
// ... error handling
// ... do stuff with the node
while(true)
{
if(FAILED(hr = reader->MoveToNextAttribute()))
// ... error handling
if(S_FALSE == hr)
break;
if(FAILED(hr = reader->GetLocalName(&attributeName, NULL)))
// ... error handling
if(FAILED(hr = reader->GetValue(&attributeValue, NULL)))
// ... error handling
// ... do stuff with the attribute
}
// ... I never see this return true, even on the node example
above
if(! xmlReader->IsEmptyElement())
// ... walk down the hierarchical tree of data
// ... note that I expect to stay put (not walk down) if the
element is empty
}
break;
case XmlNodeType_EndElement:
{
// ... walk up the hierarchical tree of data
}
break;
// ...
If anyone has used IXmlReader::IsEmptyElement successfully, can you
please tell me what you did to make it work? Or, if anyone else has
encountered the same problem, I would be encouraged to hear that,
because then I wouldn't feel so bad kludging the hierarchical logic.
I'm working on a product that is using XmlLite. Following the example
given by Microsoft on their website (http://msdn2.microsoft.com/en-us/
library/ms753116(VS.85).aspx) I have made a while loop that calls
IXmlReader::Read() and switches on the nodeType gotten. In the
example, they use IXmlReader::IsEmptyElement() to determine if a node
looks like this:
<nodeName attributeName="attributeValue" />
As I am walking through a hierarchical XML, I need to know when a node
ends. So I have both that call to IXmlReader::IsEmptyElement() and
code in the case for XmlNodeType_EndElement that walks me back up to
the parent.
Unfortunately, I am not seeing IXmlReader::IsEmptyElement() returning
true ever. The node it is reading in my testing is this:
<parameterType name="stringParameter" type="string"
multiValued="false" />
And the code reading that node is effectively this:
while(S_OK == (hr = xmlReader->Read(&nodeType)))
{
switch(nodeType)
{
case XmlNodeType_Element:
{
if(FAILED(hr = xmlReader->GetLocalName(&nodeName, NULL)))
// ... error handling
// ... do stuff with the node
while(true)
{
if(FAILED(hr = reader->MoveToNextAttribute()))
// ... error handling
if(S_FALSE == hr)
break;
if(FAILED(hr = reader->GetLocalName(&attributeName, NULL)))
// ... error handling
if(FAILED(hr = reader->GetValue(&attributeValue, NULL)))
// ... error handling
// ... do stuff with the attribute
}
// ... I never see this return true, even on the node example
above
if(! xmlReader->IsEmptyElement())
// ... walk down the hierarchical tree of data
// ... note that I expect to stay put (not walk down) if the
element is empty
}
break;
case XmlNodeType_EndElement:
{
// ... walk up the hierarchical tree of data
}
break;
// ...
If anyone has used IXmlReader::IsEmptyElement successfully, can you
please tell me what you did to make it work? Or, if anyone else has
encountered the same problem, I would be encouraged to hear that,
because then I wouldn't feel so bad kludging the hierarchical logic.