Malcz86
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 1/10/2012
-
Status: offline
|
Script to Search XML Files for open tags?
Wednesday, January 11, 2012 12:19 AM
( permalink)
Been trying to find a way to write a script which searches a XML file for a open tag. The XML file is a log and when the job is being run the XML file is incomplete. For example there's a <Tag1> but not a </Tag1>. I've tried using XML DOM to search the XML file for open tags have have had no luck. Any ideas would be appreciated.
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: online
|
Re:Script to Search XML Files for open tags?
Wednesday, January 11, 2012 6:02 AM
( permalink)
I'm not sure how the VBS regex engine will handle it, but try this regex: "^((?:<(\w++)[^>]*+(?<!/)>(?1)</\2?|[^<>]++|<\w[^>]*+/>)*+)$"
|
|
|
|
59cobalt
-
Total Posts
:
979
- Scores: 91
-
Reward points
:
0
- Joined: 7/17/2011
-
Status: offline
|
Re:Script to Search XML Files for open tags?
Wednesday, January 11, 2012 6:08 AM
( permalink)
Trying to load an incomplete XML structure into an XML DOM object should cause a parse error, because the XML is invalid. Set xml = CreateObject("MSXML.DOMDocument")
xml.Async = False
xml.ValidateOnParse = True
xml.Load "C:\foo.xml"
WScript.Echo xml.ParseError
|
|
|
|
ebgreen
-
Total Posts
:
8227
- Scores: 98
-
Reward points
:
0
- Joined: 7/12/2005
-
Status: online
|
Re:Script to Search XML Files for open tags?
Wednesday, January 11, 2012 6:13 AM
( permalink)
Oh yeah, if you just want to verify that the xml is valid, go with 59cobalt's suggestion.
|
|
|
|
Malcz86
-
Total Posts
:
2
- Scores: 0
-
Reward points
:
0
- Joined: 1/10/2012
-
Status: offline
|
Re:Script to Search XML Files for open tags?
Wednesday, January 11, 2012 11:50 PM
( permalink)
Thanks, the parse error solution does what I need. I can use the xml.parseerror.reason and a IF/Instr statement to output what tag's open.
|
|
|
|