Unsuppressable errors from XML functions

Status
Not open for further replies.
Jun 24, 2011
2
0
Hi,

I'm having a really hard time with the XML functions, specifically @XMLNODES. My XML looks like this (much simplified here):

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<storages>
  <storage id="A">
    <container id="1"></container>
  </storage>
  <storage id="B">
    <container id="2"></container>
    <include storage_id="A" />
  </storage>
</storages>

I've used the sample code from help file "XML in TCC" and tried to query number of optional nodes, in this case <include />. If I call:

Code:
@echo off
set _bla=%@XMLOPEN[xmltest.xml]
echo 1. # includes under B: %@XMLNODES[/storages/storage[@id="B"]]
echo 2  Any includes under B? %@XMLXPATH[/storages/storage[@id="B"]/include]
echo 3. # includes under A: %@XMLNODES[/storages/storage[@id="A"]]
echo 4. # of storages: %@XMLNODES[/storages]
:: everything below throws an unsuppressable error
echo 5. Any includes under A? %@XMLXPATH[/storages/storage[@id="A"]/include] > NUL
echo 6. %@XMLXPATH[/storages/storage[@id="A"]/include] || echo code: %_?
echo 7. %@XMLXPATH[/storages/storage[@id="A"]/include] >&> NUL || echo code: %_?
echo 8. # of foobar: %@XMLNODES[/foobar] >&> NUL
set _bla=%@XMLCLOSE[]

Echo 1-4 work fine and I was expecting Echo 5-8 to generate an error, but also set the var _?. However, the shown error "TCMD: (XML) Line: 0; Char: 0" is an unsuppressable one. No matter what I do, I cannot suppress it: adding "> NUL" to line, putting the line into another batch and call with call or even %@execstr[]. I suspected MSXML parser und upgraded it but it wasn't the cause. The error is simply unkillable. Since this is part of a menu-driven batch, it destroys the layout.

How can I suppress this error?

Thanks in advance!
 
May 20, 2008
3,515
4
Elkridge, MD, USA
Unsuppressable errors from @XMLNODES

---- Original Message ----
From: cytc
|...
| Code:
|
?
?

|...
| However, the error "TCMD: (XML) Line: 0; Char: 0" is an unsuppressable
| one. No matter what I do, I cannot suppress it:
| adding "> NUL" to line...
|
| How can I suppress this error?

By redirecting STDERR, not STDOUT - use ">&>" (or "2>" as in *nix), just as specified in HELP under Redirection!
--
Steve
 
May 20, 2008
12,178
133
Syracuse, NY, USA
Re: Unsuppressable errors from @XMLNODES

I tried it. The error message is going to stderr, but redirection doesn't seem to work...?

The error message is generated when the line is parsed (it is never **executed**) so it would seem that redirection is not (yet) in effect. If it's similar to the error below it can be redirected with a command group.

Code:
v:\> echo %@eval[- [5]] 2> NUL
TCC: Syntax error "- [5]"

v:\> ( echo %@eval[- [5]] ) 2> NUL

v:\>
 
Status
Not open for further replies.

Similar threads