Разбор XML с помощью VB.net и Xmldocument - PullRequest
0 голосов
/ 12 мая 2018

У меня есть несколько XML-документов, которые я анализирую с VB.Net. Я могу разобрать их все, кроме этого.

Я хочу получить значения для «число», «примечание» и «имя» из узла «входящий_дид_руте», где тип = «номер_путешествия». Я хочу вытащить значение «account_id» из дочернего узла «extension»

Ниже приведен код vb.net, который я пытаюсь использовать:

 Dim doc As New XmlDocument()
    doc.Load("filename.xml")
    Dim nodes As XmlNodeList = doc.SelectNodes("/response/result/incoming_did_routes/incoming_did_route/*")
    Dim name As String = "", number As String = "", note As String = "", account_id As String = ""
    For Each node As XmlNode In nodes
        number = node.Attributes.GetNamedItem("number").Value
        name = node.Attributes.GetNamedItem("name").Value
        note = node.Attributes.GetNamedItem("note").Value
        account_id = node.Attributes.GetNamedItem("account_id").Value
    Next

если я закомментирую номер, имя и примечание, он получит account_id. Но я не могу понять, как получить другие значения и сузить его только до type = "route_number".

Это то, что сохраняется в XML-файле:

<response method="switchvox.incomingDidRoutes.getList">
  <result>
    <incoming_did_routes total_items="4">
        <incoming_did_route type="route_number" priority="6" any_provider="1" force_fax="0" number="0000" call_type="2" note="jane doe" name="000-000-0000" id="49">
            <extension title="" type="sip" number="000" has_additional_phones="1" master_account_id="" converged="0" profile_image_link="" profile_image_id="" location="city" lang_locale="en_us" login_password_score="100" voicemail_password_score="100" phone_password_score="100" template_name="" template_id="1111" email_address="email@address.com" username="" last_name="doe" first_name="jane" type_display="Main Phone" date_created="2017-11-15 09:39:33" display="jane doe" account_id="3333" status="1" server_uuid="e28fd3d-000-jhvg6chjy7"/>
        </incoming_did_route>
        <incoming_did_route type="route_number" priority="7" any_provider="1" force_fax="0" number="0001" call_type="2" note="john doe" name="000-000-0001" id="50">
            <extension title="" type="sip" number="001" has_additional_phones="1" master_account_id="" converged="0" profile_image_link="" profile_image_id="" location="city" lang_locale="en_us" login_password_score="100" voicemail_password_score="100" phone_password_score="100" template_name="" template_id="1111" email_address="email@address.com" username="" last_name="doe" first_name="john" type_display="Main Phone" date_created="2017-11-15 09:39:33" display="jane doe" account_id="3334" status="1" server_uuid="e28fd3d-000-jhvg6chjy7"/>
        </incoming_did_route>
        <incoming_did_route type="default_route" priority="10000" id="55" sip_provider_id="000">
            <extension type="ivr" number="100" type_display="IVR" date_created="2017-08-04 11:08:53" display="Main Greeting" account_id="2" status="1" server_uuid="e28fd3d6" ivr_menu_entry_point="IVR Menu Beginning" ivr_menu_name="Main Greeting" ivr_menu_id=""/>
            <fax_extension title="" type="sip" number="003" has_additional_phones="0" master_account_id="" converged="0" profile_image_link="" profile_image_id="0" location="city" lang_locale="en_us" login_password_score="100" voicemail_password_score="100" phone_password_score="100" template_name="" template_id="1111" email_address="fax@address.com" username="" last_name="Machine" first_name="fax" type_display="Main Phone" date_created="2017-11-15 10:07:34" display="fax machine" account_id="3335" status="1" server_uuid="e28fd3d6"/>
        </incoming_did_route>
        <incoming_did_route type="catchall_unknown_route" priority="20000" id="1" action="busy"/>
    </incoming_did_routes>
  </result>
</response>

Любая помощь очень ценится!

1 Ответ

0 голосов
/ 14 мая 2018
...