我有一些我用VB.Net解析的xml文档。除了这个之外,我能够解析所有这些。
我想提取"数字","注意"和"名称"来自" incoming_did_route"节点,其中type =" route_number"。他们想要提取" account_id"的价值。来自子节点"扩展"
以下是我尝试使用的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>
非常感谢任何帮助!
答案 0 :(得分:0)