Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Unsuppressable errors from XML functions

Status
Not open for further replies.
Jun
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!
 
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
 
Re: Unsuppressable errors from @XMLNODES

---- Original Message ----
By redirecting STDERR, not STDOUT - use ">&>" (or "2>" as in *nix), just as specified in HELP under Redirection!

I tried it. The error message is going to stderr, but redirection doesn't seem to work...?
 
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:\>
 
Re: Unsuppressable errors from @XMLNODES

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.

Neat!
 
Status
Not open for further replies.

Similar threads

Back
Top