Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looking for way to display multiple values of a tag

Status
Not open for further replies.

renthorin

Technical User
Sep 3, 2003
4
US
I am trying to map a HUGE concatinated document comprised of several hundred individual documents.

I am looking for an easy way, perhaps via a utility, that will show me all the values for a specified tag.

Example:

<Pubstatus> has three values: "add", "change", "delete".

I know this to be true. What I want is something that I could define the tag <Pubstatus> and have it parse the entire document and return the 3 values "add", "change", "delete".

Anyone have any suggestions?
 
That didn't make much sense, try to explain it a bit more.

Jon

"I don't regret this, but I both rue and lament it.
 
Ummmm..........

one document comprised of many articles added together.
One tag is common to each article.

I have to do a "FIND" for the tag and read the value for each article in the concatinated document.

I write down the different values the tag has.

I want to know if there is a utility that can look through the entire document for me and display a list of all the values for that tag that it encountered.

I may end up writing a perl script but just wondering if there is anything else out there that could do that.
 
What does your XML look like? Is it this?:
Code:
<docs>
  <doc>
    <Pubstatus>
      <add>a value</add>
      <change>a value</change>
      <delete>a value</delete>
    </Pubstatus>
  </doc>
  <doc>
    <Pubstatus>
      <add>a value</add>
      <change>a value</change>
      <delete>a value</delete>
    </Pubstatus>
  </doc>
  ......
</docs>
If so its easy to return the values. Best way depends on what you want to do with them. If you simply want to get them on a one-off, you can just download XMLSpy and write a simple stylesheet. If you want to make it into a dynamic application, you'll have to incorporate the stylesheet into some sort of program. Perl has XSL modules:


I've never used them myself, I tend to use C# .net.

Jon

"I don't regret this, but I both rue and lament it.
 
No, my document looks like:

<docs>
<doc>
<Pubstatus status= "add">
</Pubstatus>
</doc>

<docs>
<doc>
<Pubstatus status= "add">
</Pubstatus>
</doc>

<docs>
<doc>
<Pubstatus status= "change">
</Pubstatus>
</doc>


and I need to know out of the 800+ documents what all of the different values for "status=" are.

In this case it would return 2 vaules: "add" and "change
 
Oops! Your XML is not well-formed. Can you change this to the following?
Code:
<docs>
  <doc>
    <Pubstatus status= "add">
    </Pubstatus>
  </doc>

  <doc>
    <Pubstatus status= "add">
    </Pubstatus>
  </doc>

  <doc>
    <Pubstatus status= "change">
    </Pubstatus>
  </doc>

</docs>

Tom Morrison
 
renthorin

If you can make the minor change suggest here, you can easily accomplish what you want to do.

Please reply!

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top