Parsing a text file

(imported topic written by FITZPAW91)

Hi

I am trying to return information from a text file that would be located in the middle of a line (I don’t want the information before or after). The problem being is that the same line might be repeated multiple times. There are quotes in my text file also, to make searching harder

example

I would like to get 8/10/2009 - Version 8.3.0.3320A from this, without the "/> at end

Thanks

William

(imported comment written by MattBoyd)

Hey Will,

Is this an xml-structured file? If so, it would probably be a lot easier to parse out the values you want using the xml inspectors. If it is xml, can you post a sample of what the complete file might look like? I should be able to help with the relevance.

(imported comment written by FITZPAW91)

Thanks Boyd

The file is an XML, but the file is 1/2 mb large, so I took some lines from the XML to give you an example. If you need the whole file, I will upload it.

Where can I find a list of XML Inspectors for future use

Thanks

William

(imported comment written by MattBoyd)

I think this is all of the inspectors:

http://support.bigfix.com/cgi-bin/inspectorsearch/inspector_search.cgi?keyphrase=&keyphrase=xml&client=1&core=1

That’s a big file and I don’t really need all of it. I really only need an example of all the parent XML tags (AKA elements) that are in it so that I can make sure that the select is right. For example, this would be helpful:

(imported comment written by FITZPAW91)

Hope this helps. As you can see the entries are doubled.

<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type= "text/xsl" href="http://wtec.cup.hp.com/~nos/HPSviewer/1/survey.xsl"?>

Thanks alot for your help

William

(imported comment written by jessewk)

Try:

Q: unique values of node values of attributes “description” of xpaths “/diagOutput/category/structure/structure” of xml document of file “c:\test.xml”

A: 8/10/2009 - Version 8.3.0.3320A

Note that I put the contents of the file in c:\test.xml.

(imported comment written by FITZPAW91)

Thanks Jesse

That works great, but does not really solve my issue. What if I want to get the Value of <property name="ProductName which will vary, but this time I want the value “Embedded NEC98431” and not “Proliant BL20P” or “NoValue” from the following…?

(BTW - I copied and pasted parts of XML so it might be missing a tag)

<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type= "text/xsl" href="http://wtec.cup.hp.com/~nos/HPSviewer/1/survey.xsl"?>

Thanks

William

(imported comment written by MattBoyd)

Hey Will,

I’m a bit confused about what output you would like from that second xml document. Could you give us some context about the problem you’re trying to solve and what information you’d like returned from the query?

(imported comment written by FITZPAW91)

Hi Boyd

Maybe it is because I don’t fully understand this XML parsing, but here we go.

As you can see the entry and

both contain <property name=“productName” caption=“Nom du produit” but have different value=, and are located in different sections of the XML file. I am trying to get information from one but not from the other, so I can put it in an analysis and see all the hardware that is on my servers, which BigFix does not supply out of the box.

Hope this helps, I can supply more info if needed.

Thanks

William

(imported comment written by FITZPAW91)

Hello

Seems like the information that I am looking for is in post http://forum.bigfix.com/viewtopic.php?id=1542, but now I am trying to modify the results to produce strings, not numerical values

node values of attributes “value” of xpaths “/diagOutput/category/device/structure/property”

whose

(

node value of attribute “name” of it = “IPAddress”

)

of xml document of file “c:\devices.xml”

Thanks

William

(imported comment written by MattBoyd)

Ok, I

think

I understand what you’re looking for. How does this look:

node values of attributes 
"value" of xpaths 
"//property" whose ( node value of attribute 
"name" of it as lowercase = 
"productname" and (node value of attribute 
"value" of it as lowercase != 
"novalue") and (node value of attribute 
"value" of it as lowercase != 
"proliant bl20p g3") ) of xml document of file 
"c:\test.xml"

By the way, here’s a tutorial on xpath: http://www.w3schools.com/XPath/default.asp

(imported comment written by FITZPAW91)

Thanks Boyd,

Seems to work, and I appreciate the tutuorial.

Have a great weekend

William

(imported comment written by olsonc5891)

Hey guys,

I am very new at this and need to search for value in an xml file . The file is below with the value; 5th line from the bottom (). Can you help? Once I find it, I’ll want to modify it to read

This is a bit above me. Maybe it can’t even be done but any insight would be appreciated.

Thanks,

Chris

<?xml version="1.0" encoding="utf-8" ?>