473,385 Members | 1,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XML Parsing

How does one convert XML content or text within an XML element to sub-elements within the parent element? I am trying to use C# which calls a XSL file.

The application is trying to parse the "msg" text in a Syslog server data string to retrieve the src and dest IP addresses as well as the true message.
Oct 12 '08 #1
5 1998
Dormilich
8,658 Expert Mod 8TB
basically copy everything except that what you want to change and insert the elements to change in a separate template.

(maybe) useful threads:
https://bytes.com/showthread.php?t=842976
https://bytes.com/showthread.php?t=841347
regards
Oct 13 '08 #2
I am still not sure how to get xml tags around XML content within a single element. The content I want to tag is multiple strings that are currently with another XML tag. For example; <MsgText>id=xxxxxx srcIP=xxx.xxx.xxx.xxx destIP=xxx.xxx.xxx.xxx msg=xxxxxxx</MsgText>

I want to break out each of those pieces of content into their own tags.
Oct 13 '08 #3
Dormilich
8,658 Expert Mod 8TB
then you need some string operations.

see
https://bytes.com/showthread.php?t=829025

regards
Oct 14 '08 #4
There sure is a lot to go through to separate text within a XML file into individual XML tags.

I will have to muddle through it.

I was able to get my XSL file to strip all tags out of the XML. So, I thought I might be able to use Regex within the C# code to separate the individual text components and add XML tags back in.

I just need the pertinent syslog data components to be separated out of the Syslog message so I can store them back in a MySql table.

Thanks.
Oct 15 '08 #5
Dormilich
8,658 Expert Mod 8TB
If you're doing the "hard" work (meaning the regex) in C# you can as well transform the whole xml file in C#. on the other hand side if you want to use xslt you should let it do all the work (though I have to admit that xsl is a rather lousy programming language). If I remember right you can use a regex in XSLT 2.0. but until then you have to access each parameter separately.
Expand|Select|Wrap|Line Numbers
  1. // taken from the last mentioned thread
  2. // call it from MsgText's parent or change the path on line 12
  3. // this will output the parameter (named in $attrName)
  4. <xsl:template name="getAttr">
  5.     <xsl:param name="attrName"/>
  6.     <xsl:param name="pattern">
  7.         <xsl:value-of select="$attrName"/>
  8.         <xsl:text>=</xsl:text>
  9.     </xsl:param>
  10. // further output code here ...
  11. // extract string from $pattern up to the next space
  12.     <xsl:value-of select="substring-before(substring-after(MsgText, $pattern), ' ')"/>
  13. // ... and here
  14. </xsl:template>
regards
Oct 15 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
0
by: Pentti | last post by:
Can anyone help to understand why re-parsing occurs on a remote database (using database links), even though we are using a prepared statement on the local database: Scenario: ======== We...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
5
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
by: toton | last post by:
Hi, I have some ascii files, which are having some formatted text. I want to read some section only from the total file. For that what I am doing is indexing the sections (denoted by .START in...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
7
by: Daniel Fetchinson | last post by:
Many times a more user friendly date format is convenient than the pure date and time. For example for a date that is yesterday I would like to see "yesterday" instead of the date itself. And for...
1
by: eyeore | last post by:
Hello everyone my String reverse code works but my professor wants me to use pop top push or Stack code and parsing code could you please teach me how to make this code work with pop top push or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.