Search in XML files
Moderator: DosItHelp
Search in XML files
Hi,
I have multiples of XML files in folder c:/xml and need to search for a numeric value or string, without opening the files and once the value is located then display the particular file name on console, condition is that it should run the search on all the xml files and output the search result on console.
Thanks in advance.
I have multiples of XML files in folder c:/xml and need to search for a numeric value or string, without opening the files and once the value is located then display the particular file name on console, condition is that it should run the search on all the xml files and output the search result on console.
Thanks in advance.
Re: Search in XML files
Code: Select all
findstr /M "search string" c:\xml\*.xml
Antonio
Re: Search in XML files
Hi,
Aacini, i need some more help.
Search value in c:\xml and its sub folders, and if value is found in any of xml file then get the tag <clntId> and <priority> values on the console.
Thanks in advance.
Aacini, i need some more help.
Search value in c:\xml and its sub folders, and if value is found in any of xml file then get the tag <clntId> and <priority> values on the console.
Thanks in advance.
Re: Search in XML files
zagix wrote:Aacini, i need some more help.
Search value in c:\xml and its sub folders, and if value is found in any of xml file then get the tag <clntId> and <priority> values on the console.
Give your task a good think and then help Aacini to help you by giving him your entire task in one go.
Re: Search in XML files
zagix
Batch doesn't support XML parsing.
... is the same as ...
... and both valid parts in an XML file.
We would need to know the entire content of such an XML file. Then we could decide what language or hybrid script could be applicable to read the values.
Regards
aGerman
Batch doesn't support XML parsing.
Code: Select all
<foo>123</foo><bar>abc</bar>
... is the same as ...
Code: Select all
<foo>123</foo>
<bar>abc</bar>
... and both valid parts in an XML file.
We would need to know the entire content of such an XML file. Then we could decide what language or hybrid script could be applicable to read the values.
Regards
aGerman
Re: Search in XML files
If you dont mind using powershell and can follow the method used here
you could change the second line to:…and see how you go!
you could change the second line to:
Code: Select all
$Files = ls $Path -R -I *.xml | Select-String "My Search String" -list | % { $_.path }
Re: Search in XML files
Hi,
Compo, on testing i am getting this error.
Compo, on testing i am getting this error.
Code: Select all
PS C:\Users\S> C:\Test\LatLonAlt.ps1
Get-Content : Cannot bind argument to parameter 'Path' because it is null.
At C:\Test\LatLonAlt.ps1:11 char:32
+ [XML] $Content = Get-Content <<<< $File.FullName
+ CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.GetContentCommand
Re: Search in XML files
I'd like to make an observation that technical forums such a dostips have an element of social interaction in them also and it's not all that pleasant to see people arrive to ask a question and then ignore those other people who have taken the time to make comments or provide code or suggestions.
This happens far too often in modern days and I become grumpy; as within me it amounts to rudeness on the part of people seeking free help to save themselves some time.
When batch scripting was the sole domain of enthusiasts who were learning how to wring new abilities out of MSDOS it was a very respectful and friendly environment. The new things in modern days are the frequent arguments, and the unwillingness to provide details about a task, and getting an answer and shooting through with no comment at all.
There weren't many places you could natter about batch files in those past times so multi-posting wasn't around then either.
I should tattoo a slogan on my forehead saying "Grumpy old fart."
This happens far too often in modern days and I become grumpy; as within me it amounts to rudeness on the part of people seeking free help to save themselves some time.
When batch scripting was the sole domain of enthusiasts who were learning how to wring new abilities out of MSDOS it was a very respectful and friendly environment. The new things in modern days are the frequent arguments, and the unwillingness to provide details about a task, and getting an answer and shooting through with no comment at all.
There weren't many places you could natter about batch files in those past times so multi-posting wasn't around then either.
I should tattoo a slogan on my forehead saying "Grumpy old fart."