EDN Admin
Well-known member
Hi, thanks for taking the time to read my post. I am currently working on a project where I must capture serial port data which is usually displayed on a VT100 terminal from a Microcontroller, I have tried and failed using a regex to format the data correctly
as I must get the name of the function and its value, ideally in to an array of object to utilizes in the code. For the purpose of illustration please see the sample of data I am working with;
<pre> : 0E[2H 1 IGBT Alarm #1 : 1E 1 IGBT Alarm #2 : 1E <br/>
0 IGBT Alarm #3 : 1E 0 IGBT Alarm #4 : 1E 0 IGBT Alarm #5 : 1E <br/>
1 IGBT Alarm #6 : 1E 1 IGBT Alarm #7 : 1E 0 Digital Input #1 : 0EConfig Input #1 : 0 <br/>
Digital Input #2 : 0EConfig Input #2 : 0 Digital Input #3 : 0EConfig Input #3 : 0 Digital Input #4 : 0&
<div style="background-color:white; color:black
<pre><span style="color:blue <<span style="color:#a31515 b <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue nmspc<span style="color:black " <span style="color:blue />
[/code]
whats the xpath syntax to grab this elements?
I can get it with
<pre lang="x-c# XmlNamespaceManager xnsMgr = ...
xmlDoc.DocumentElement.SelectNodes(string.Format("//{0}:*", prefix), xnsMgr)
[/code]
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small but i would like to target element that explicitly has that xmlns attribute, i tried below, non of them worked:
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<pre lang="x-c# XmlNodeList xNs2 = xmlDoc.DocumentElement.SelectNodes(string.Format("//*[@xmlns={0}]", uri), xnsMgr);
XmlNodeList xNs4 = xmlDoc.DocumentElement.SelectNodes(string.Format("//*[@xmlns={0}]", uri));
XmlNodeList xNs3 = xmlDoc.DocumentElement.SelectNodes(string.Format("//{0}:*[@xmlns={1}]", prefix, uri), xnsMgr);
[/code]
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small
<span style="font-family:Consolas; font-size:x-small
View the full article
as I must get the name of the function and its value, ideally in to an array of object to utilizes in the code. For the purpose of illustration please see the sample of data I am working with;
<pre> : 0E[2H 1 IGBT Alarm #1 : 1E 1 IGBT Alarm #2 : 1E <br/>
0 IGBT Alarm #3 : 1E 0 IGBT Alarm #4 : 1E 0 IGBT Alarm #5 : 1E <br/>
1 IGBT Alarm #6 : 1E 1 IGBT Alarm #7 : 1E 0 Digital Input #1 : 0EConfig Input #1 : 0 <br/>
Digital Input #2 : 0EConfig Input #2 : 0 Digital Input #3 : 0EConfig Input #3 : 0 Digital Input #4 : 0&
<div style="background-color:white; color:black
<pre><span style="color:blue <<span style="color:#a31515 b <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue nmspc<span style="color:black " <span style="color:blue />
[/code]
whats the xpath syntax to grab this elements?
I can get it with
<pre lang="x-c# XmlNamespaceManager xnsMgr = ...
xmlDoc.DocumentElement.SelectNodes(string.Format("//{0}:*", prefix), xnsMgr)
[/code]
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small but i would like to target element that explicitly has that xmlns attribute, i tried below, non of them worked:
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<pre lang="x-c# XmlNodeList xNs2 = xmlDoc.DocumentElement.SelectNodes(string.Format("//*[@xmlns={0}]", uri), xnsMgr);
XmlNodeList xNs4 = xmlDoc.DocumentElement.SelectNodes(string.Format("//*[@xmlns={0}]", uri));
XmlNodeList xNs3 = xmlDoc.DocumentElement.SelectNodes(string.Format("//{0}:*[@xmlns={1}]", prefix, uri), xnsMgr);
[/code]
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small
<span style="font-family:Consolas; font-size:x-small
View the full article