Ich bin sehr neu in XML mit C# Ich habe ein XML Ich muss durch bestimmte Kinder in der Eltern gehen Ich brauche die ID und die Variable Variablen Variablen, die ich tat, aber Jedes Mal ging nicht durch die SchleifeNachkommen in C# geben nicht den richtigen Wert
Muss ich durch alle Eltern von XML gehen, bis ich den Baum, den ich will ??
die xml
<message xmlns="jabber:client" to="[email protected]" id="/finesse/api/User/1072/[email protected]__104Y2" from="pubsub.finesse1.dcloud.cisco.com">
<event xmlns="http://jabber.org/protocol/pubsub#event">
<items node="/finesse/api/User/1072/Dialogs">
<item id="460c2d27-c914-4c24-a95f-edf9f8df45c21535">
<notification xmlns="http://jabber.org/protocol/pubsub">
<Update>
<data>
<dialogs>
<Dialog>
<associatedDialogUri></associatedDialogUri>
<fromAddress>1071</fromAddress>
<id>18639330</id>
<mediaProperties>
<DNIS>1072</DNIS>
<callType>AGENT_INSIDE</callType>
<dialedNumber>1072</dialedNumber>
<outboundClassification></outboundClassification>
<callvariables>
<CallVariable>
<name>callVariable1</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable2</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable3</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable4</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable5</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable6</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable7</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable8</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable9</name>
<value></value>
</CallVariable>
<CallVariable>
<name>callVariable10</name>
<value></value>
</CallVariable>
</callvariables>
</mediaProperties>
<mediaType>Voice</mediaType>
<participants>
<Participant>
<actions>
<action>ANSWER</action>
</actions>
<mediaAddress>1072</mediaAddress>
<mediaAddressType>AGENT_DEVICE</mediaAddressType>
<startTime>2017-09-15T19:23:36.872Z</startTime>
<state>ALERTING</state>
<stateCause></stateCause>
<stateChangeTime>2017-09-15T19:23:36.872Z</stateChangeTime>
</Participant>
<Participant>
<actions>
<action>UPDATE_CALL_DATA</action>
<action>DROP</action>
</actions>
<mediaAddress>1071</mediaAddress>
<mediaAddressType>AGENT_DEVICE</mediaAddressType>
<startTime>2017-09-15T19:23:36.609Z</startTime>
<state>INITIATED</state>
<stateCause></stateCause>
<stateChangeTime>2017-09-15T19:23:36.819Z</stateChangeTime>
</Participant>
</participants>
<state>ALERTING</state>
<toAddress>1072</toAddress>
<uri>/finesse/api/Dialog/18639330</uri>
</Dialog>
</dialogs>
</data>
<event>POST</event>
<requestId></requestId>
<source>/finesse/api/User/1072/Dialogs</source>
</Update>
</notification>
</item>
</items>
</event>
</message>
, die dem -Code ist
XElement xmlroots = XElement.Parse(parsingNewXML);
//Dialog = xmlroots.Element("Dialog").Value;
var CallVariable = parsingNewXML.Contains("CallVariable");
var startCall = parsingNewXML.Contains("ALERTING");
if (CallVariable == true && startCall == true)
{
foreach (XElement callID in xmlroots.Descendants("Dialog"))
{
DialogID = callID.Element("id").Value;
//System.Windows.MessageBox.Show(DialogID);
System.Windows.Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Background,
new Action(() => ((MainWindow)System.Windows.Application.Current.MainWindow).answerCall.Visibility = Visibility.Visible));
}
foreach (XElement callVariables in xmlroots.Descendants("CallVariables"))
{
foreach (XElement callVariable in xmlroots.Descendants("CallVariable"))
{
list = callVariable.Element("value").Value;
}
}
// state = second.Element("state").Value;
}
Ihr Code und das XML sind nicht konsistent. Ich kann nicht sagen, was du brauchst. Die "if" -Klausel ergibt keinen Sinn. Keine Ahnung, worauf sich parsingmsg bezieht. Es ist viel einfacher, Nachkommen anstelle von Vorfahren zu verwenden. – jdweng
@jdweng bitte helfen Sie mir Ich möchte die ID von diesem XML bekommen was soll ich tun Ich weiß nicht, was ist der Code zu schreiben, um die ID zu bekommen Ich versuchte diesen Code, aber hat mir nicht geholfen – bavs